std::shared_mutex::shared_mutex

shared_mutex(); (1) (since C++17) shared_mutex( const shared_mutex& ) = delete; (2) (since C++17) 1) Constructs the mutex. The mutex is in unlocked state after the call. 2) Copy constructor is deleted. Parameters (none). Exceptions std::system_error if the construction is unsuccessful.

std::shared_mutex::try_lock

bool try_lock(); (since C++17) Tries to lock the mutex. Returns immediately. On successful lock acquisition returns true, otherwise returns false. This function is allowed to fail spuriously and return false even if the mutex is not currently locked by any other thread. If try_lock is called by a thread that already owns the mutex in any mode (shared or exclusive), the behavior is undefined. Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) t

std::shared_mutex::try_lock_shared

bool try_lock_shared(); (since C++17) Tries to lock the mutex in shared mode. Returns immediately. On successful lock acquisition returns true, otherwise returns false. This function is allowed to fail spuriously and return false even if the mutex is not currenly exclusively locked by any other thread. Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation if it returns true. The behavior is undefined if the calling thread already o

std::shared_mutex::native_handle

native_handle_type native_handle(); (since C++17) (optional) Returns the underlying implementation-defined native handle object. Parameters (none). Return value Implementation-defined native handle object. Exceptions Implementation-defined. Example

std::shared_lock::unlock

void unlock(); (since C++14) Unlocks the associated mutex from shared mode. Effectively calls mutex()->unlock_shared(). std::system_error is thrown if there is no associated mutex or if the mutex is not locked. Parameters (none). Return value (none). Exceptions Any exceptions thrown by mutex()->unlock_shared() If there is no associated mutex, std::system_error with an error code of std::errc::operation_not_permitted Example See also lock locks the associat

std::shared_mutex

Defined in header <shared_mutex> class shared_mutex; (since C++17) The shared_mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads. In contrast to other mutex types which facilitate exclusive access, a shared_mutex has two levels of access: shared - several threads can share ownership of the same mutex. exclusive - only one thread can own the mutex. Shared mutexes are usually used in

std::shared_mutex::lock

void lock(); (since C++17) Locks the mutex. If another thread has already locked the mutex, a call to lock will block execution until the lock is acquired. If lock is called by a thread that already owns the mutex in any mode (shared or exclusive), the behavior is undefined. Prior unlock() operation on the same mutex synchronizes-with (as defined in std::memory_order) this operation. Parameters (none). Return value (none). Exceptions Throws std::system_error when errors occur,

std::shared_lock::try_lock_until

template< class Clock, class Duration > bool try_lock_until( const std::chrono::time_point<Clock,Duration>& timeout_time ); (since C++14) Tries to lock the associated mutex in shared mode. Blocks until specified timeout_time has been reached or the lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. May block for longer than until timeout_time has been reached. Effectively calls mutex()->try_lock_shared_until(

std::shared_lock::release

mutex_type* release(); (since C++14) 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. Parameters (none). Return value Pointer to the associated mutex or NULL if there was no associated mutex. Exceptions noexcept specification: noexcept Example See also unlock unlocks the associated mutex (public member fun

std::shared_lock::owns_lock

bool owns_lock() const; (since C++14) Checks whether *this owns a locked mutex or not. Parameters (none). Return value true if *this has an associated mutex and has acquired shared ownership of it, false otherwise. Exceptions noexcept specification: noexcept See also operator bool tests whether the lock owns its associated mutex (public member function)