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::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::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_mutex::lock_shared

void lock_shared(); (since C++17) Acquires shared ownership of the mutex. If another thread is holding the mutex in exclusive ownership, a call to lock_shared will block execution until shared ownership can be acquired. If lock_shared is called by a thread that already owns the mutex in any mode (exclusive or shared), the behavior is undefined. If more than the implementation-defined maximum number of shared owners already locked the mutex in shared mode, lock_shared blocks execution un

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_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_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_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::try_lock_for

template< class Rep, class Period > bool try_lock_for( const std::chrono::duration<Rep,Period>& timeout_duration ); (since C++14) Tries to lock the associated mutex in shared mode. 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_shared_for(timeout_duration). A steady clock is used to measure the duration. This fu

std::shared_lock::try_lock

bool try_lock(); (since C++14) Tries to lock the associated mutex in shared mode without blocking. Effectively calls mutex()->try_lock_shared(). std::system_error is thrown if there is no associated mutex or if the mutex is already locked. Parameters (none). Return value true if the ownership of the mutex has been acquired successfully, false otherwise. Exceptions Any exceptions thrown by mutex()->try_lock_shared() If there is no associated mutex, std::system_error wit