7#include <condition_variable>
9#include <yaclib_std/chrono>
10#include <yaclib_std/mutex>
19template <
typename Impl>
24 using Impl::native_handle;
34 void wait(std::unique_lock<yaclib_std::mutex>& lock) {
40 template <
typename Predicate>
47 template <
typename Rep,
typename Period>
48 std::cv_status
wait_for(std::unique_lock<yaclib_std::mutex>& lock,
49 const std::chrono::duration<Rep, Period>&
rel_time) {
55 template <
typename Rep,
typename Period,
typename Predicate>
56 bool wait_for(std::unique_lock<yaclib_std::mutex>& lock,
const std::chrono::duration<Rep, Period>&
rel_time,
64 template <
typename Clock,
typename Duration>
65 std::cv_status
wait_until(std::unique_lock<yaclib_std::mutex>& lock,
66 const std::chrono::time_point<Clock, Duration>&
timeout_time) {
72 template <
typename Clock,
typename Duration,
typename Predicate>
73 bool wait_until(std::unique_lock<yaclib_std::mutex>& lock,
82 static auto From(std::unique_lock<yaclib_std::mutex>& lock) {
83 YACLIB_DEBUG(!lock.owns_lock(),
"Trying to call wait on not owned lock");
84 auto* mutex = lock.release();
86 return std::tuple<yaclib_std::mutex*, std::unique_lock<yaclib_std::mutex::impl_t>>{
87 mutex, std::unique_lock{mutex->GetImpl(), std::adopt_lock}};
92 return std::unique_lock{*
mutex, std::adopt_lock};
bool wait_for(std::unique_lock< yaclib_std::mutex > &lock, const std::chrono::duration< Rep, Period > &rel_time, Predicate &&stop_waiting)
void notify_all() noexcept
bool wait_until(std::unique_lock< yaclib_std::mutex > &lock, const std::chrono::time_point< Clock, Duration > &timeout_time, Predicate &&stop_waiting)
std::cv_status wait_until(std::unique_lock< yaclib_std::mutex > &lock, const std::chrono::time_point< Clock, Duration > &timeout_time)
void wait(std::unique_lock< yaclib_std::mutex > &lock, Predicate &&stop_waiting)
std::cv_status wait_for(std::unique_lock< yaclib_std::mutex > &lock, const std::chrono::duration< Rep, Period > &rel_time)
void wait(std::unique_lock< yaclib_std::mutex > &lock)
void notify_one() noexcept
#define YACLIB_INJECT_FAULT(statement)
#define YACLIB_DEBUG(cond, message)
constexpr std::cv_status CVStatusFrom(WaitStatus)
Contract< V, E > MakeContract()
Creates related future and promise.