|
constexpr | unique_lock () noexcept=default |
| Constructs a unique_lock with no associated mutex.
|
|
constexpr | unique_lock (mutex_type &m) |
| Constructs a unique_lock with m as the associated mutex. Additionally: Locks the associated mutex by calling m.lock(). The behavior is undefined if the current thread already owns the mutex except when the mutex is recursive.
|
|
constexpr | unique_lock (mutex_type &m, adopt_lock_t) |
| Constructs a unique_lock with m as the associated mutex. Additionally: Assumes the calling thread already owns m.
|
|
template<typename Rep, typename Period> |
constexpr | unique_lock (mutex_type &m, chrono::duration< Rep, Period > const &relTime) noexcept |
| Constructs a unique_lock with m as the associated mutex. Additionally: Tries to lock the associated mutex by calling m.try_lock_for(timeout_duration). Blocks until specified timeout_duration has elapsed or the lock is acquired, whichever comes first. May block for longer than timeout_duration.
|
|
template<typename Clock, typename Duration> |
constexpr | unique_lock (mutex_type &m, chrono::time_point< Clock, Duration > const &absTime) noexcept |
| Constructs a unique_lock with m as the associated mutex. Additionally: Tries to lock the associated mutex by calling m.try_lock_until(timeout_time). Blocks until specified timeout_time has been reached or the lock is acquired, whichever comes first. May block for longer than until timeout_time has been reached.
|
|
constexpr | unique_lock (mutex_type &m, defer_lock_t) noexcept |
| Constructs a unique_lock with m as the associated mutex. Additionally: Does not lock the associated mutex.
|
|
constexpr | unique_lock (mutex_type &m, try_to_lock_t) noexcept |
| Constructs a unique_lock with m as the associated mutex. Additionally: Tries to lock the associated mutex without blocking by calling m.try_lock(). The behavior is undefined if the current thread already owns the mutex except when the mutex is recursive.
|
|
constexpr | unique_lock (unique_lock &&u) noexcept |
| Move constructor. Initializes the unique_lock with the contents of other. Leaves other with no associated mutex.
|
|
constexpr | unique_lock (unique_lock const &)=delete |
| Deleted copy constructor. unique_lock is move only.
|
|
constexpr | ~unique_lock () noexcept |
|
constexpr auto | lock () noexcept(noexcept(_mutex->lock())) -> void |
| Locks (i.e., takes ownership of) the associated mutex.
|
|
constexpr auto | mutex () const noexcept -> mutex_type * |
| Returns a pointer to the associated mutex, or a null pointer if there is no associated mutex.
|
|
constexpr | operator bool () const noexcept |
| Checks whether *this owns a locked mutex or not.
|
|
constexpr auto | operator= (unique_lock &&u) noexcept -> unique_lock & |
| Move assignment operator. Replaces the contents with those of other using move semantics. If prior to the call *this has an associated mutex and has acquired ownership of it, the mutex is unlocked.
|
|
constexpr auto | operator= (unique_lock const &) -> unique_lock &=delete |
| Deleted copy assignment. unique_lock is move only.
|
|
constexpr auto | owns_lock () const noexcept -> bool |
| Checks whether *this owns a locked mutex or not.
|
|
constexpr auto | release () noexcept -> mutex_type * |
| Breaks the association of the associated mutex, if any, and *this. No locks are unlocked. If the *this held ownership of the associated mutex prior to the call, the caller is now responsible to unlock the mutex.
|
|
constexpr auto | swap (unique_lock &other) noexcept -> void |
| Exchanges the internal states of the lock objects.
|
|
constexpr auto | try_lock () noexcept(noexcept(_mutex->try_lock())) -> bool |
| Tries to lock (i.e., takes ownership of) the associated mutex without blocking.
|
|
template<typename Rep, typename Period> |
constexpr auto | try_lock_for (chrono::duration< Rep, Period > const &dur) noexcept(noexcept(_mutex->try_lock_for(dur))) -> bool |
| Tries to lock (i.e., takes ownership of) the associated mutex. Blocks until specified timeout_duration has elapsed or the lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. Effectively calls mutex()->try_lock_for(timeout_duration). This function may block for longer than timeout_duration due to scheduling or resource contention delays.
|
|
template<typename Clock, typename Duration> |
constexpr auto | try_lock_until (chrono::time_point< Clock, Duration > const &tp) noexcept(noexcept(_mutex->try_lock_until(tp))) -> bool |
| Tries to lock (i.e., takes ownership of) the associated mutex without blocking.
|
|
constexpr auto | unlock () -> void |
| Unlocks (i.e., releases ownership of) the associated mutex and releases ownership. Silently does nothing, if there is no associated mutex or if the mutex is not locked.
|
|
template<typename Mutex>
struct etl::unique_lock< Mutex >
The struct unique_lock is a general-purpose mutex ownership wrapper allowing deferred locking, time-constrained attempts at locking, recursive locking, transfer of lock ownership, and use with condition variables.
The struct unique_lock is movable, but not copyable – it meets the requirements of MoveConstructible and MoveAssignable but not of CopyConstructible or CopyAssignable. The struct unique_lock meets the BasicLockable requirements. If Mutex meets the Lockable requirements, unique_lock also meets the Lockable requirements (ex.: can be used in lock); if Mutex meets the TimedLockable requirements, unique_lock also meets the TimedLockable requirements.