79 #include <condition_variable> 93 , std::condition_variable_any
98 wait (PRED&& predicate)
100 condVar().wait (mutex(), std::forward<PRED> (predicate));
106 template<
class REPR,
class PERI,
class PRED>
108 wait_for (std::chrono::duration<REPR, PERI>
const& timeout, PRED&& predicate)
110 return condVar().wait_for (mutex(), timeout, std::forward<PRED> (predicate));
116 return static_cast<MTX&
> (*this);
118 std::condition_variable_any&
121 return static_cast<std::condition_variable_any&
> (*this);
128 void unlock() noexcept { }
147 void lock() { IMPL::lock(); }
148 void unlock() noexcept { IMPL::unlock(); }
150 void notify_one() noexcept { IMPL::notify_one(); }
151 void notify_all() noexcept { IMPL::notify_all(); }
155 wait (PRED&& predicate)
157 IMPL::wait (std::forward<PRED>(predicate));
160 template<
class DUR,
class PRED>
162 wait_for (DUR
const& timeout, PRED&& predicate)
164 return IMPL::wait_for (timeout, std::forward<PRED> (predicate));
168 using NonrecursiveLock_NoWait = std::mutex;
169 using RecursiveLock_NoWait = std::recursive_mutex;
187 using sync::NonrecursiveLock_NoWait;
189 using sync::RecursiveLock_NoWait;
216 template<
class CONF = NonrecursiveLock_NoWait>
220 mutable Monitor objectMonitor_;
224 getMonitor(
Sync const* forThis)
227 return forThis->objectMonitor_;
241 Lock(X* it) : mon_{getMonitor(it)}{ mon_.lock(); }
242 ~
Lock() { mon_.unlock(); }
244 void notify_one() { mon_.notify_one(); }
245 void notify_all() { mon_.notify_all(); }
249 wait (PRED&& predicate)
251 mon_.wait (std::forward<PRED>(predicate));
254 template<
class DUR,
class PRED>
256 wait_for (DUR
const& timeout, PRED&& predicate)
258 return mon_.wait_for (timeout, std::forward<PRED> (predicate));
264 template<
class X,
class PRED>
266 : mon_(getMonitor(it))
270 mon_.wait (std::forward<PRED>(predicate));
Facility for monitor object based locking.
Lock(Monitor &m)
for creating a ClassLock
Any copy and copy construction prohibited.
scoped guard to control the actual locking.
Implementation namespace for support and library code.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
bool wait_for(std::chrono::duration< REPR, PERI > const &timeout, PRED &&predicate)
Lock(X *it, PRED &&predicate)
convenience shortcut: Locks and immediately enters wait state on the given predicate ...
Lumiera error handling (C++ interface).
Monitor & accessMonitor()
subclass access to underlying sync primitives
Object Monitor for synchronisation and waiting.