17 template<
class T,
class M = std::mutex>
34 std::lock_guard<mutex_t>
lock() {
35 return std::lock_guard {_lock};
43 template<
class... Args>
45 raw {std::forward<Args>(
args)...} {
55 std::lock(_lock, other._lock);
57 raw = std::move(other.raw);
72 std::lock(_lock, other._lock);
120 raw = std::move(val);
Value wrapper that pairs an object with the mutex protecting it.
Definition sync.h:18
sync_t & operator=(sync_t &other) noexcept
Copy another synchronized value into this instance while locking both wrappers.
Definition sync.h:71
sync_t & operator=(sync_t &&other) noexcept
Move another synchronized value into this instance while locking both wrappers.
Definition sync.h:54
sync_t & operator=(value_t &&val) noexcept
Move-assign the protected value while holding this wrapper's lock.
Definition sync.h:117
T value_t
Type stored behind the synchronization wrapper.
Definition sync.h:23
const value_t & operator*() const
Dereference the protected value.
Definition sync.h:148
M mutex_t
Mutex type used to protect the stored value.
Definition sync.h:27
value_t raw
Protected value accessed while this helper's lock is held.
Definition sync.h:152
value_t & operator*()
Dereference the protected value.
Definition sync.h:139
std::lock_guard< mutex_t > lock()
Acquire the underlying lock or keyed mutex.
Definition sync.h:34
sync_t(Args &&...args)
Initialize the protected object from forwarded arguments.
Definition sync.h:44
sync_t & operator=(V &&val)
Assign a new value while holding this wrapper's lock.
Definition sync.h:89
value_t * operator->()
Access the protected value directly.
Definition sync.h:130
sync_t & operator=(const value_t &val) noexcept
Copy-assign the protected value while holding this wrapper's lock.
Definition sync.h:103
Functions for handling command line arguments.
Definition entry_handler.cpp:37