std::shared_timed_mutex::try_lock_shared_for

template< class Rep, class Period > bool try_lock_shared_for( const std::chrono::duration<Rep,Period>& timeout_duration ); (since C++14) Tries to lock the mutex in shared mode. Blocks until specified timeout_duration has elapsed or the shared lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. If timeout_duration is less or equal timeout_duration.zero(), the function behaves like try_lock_shared(). A steady clock

std::shared_timed_mutex

Defined in header <shared_mutex> class shared_timed_mutex; (since C++14) The shared_timed_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_timed_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 ar

std::shared_timed_mutex::shared_timed_mutex

shared_timed_mutex(); (1) (since C++14) shared_timed_mutex( const shared_timed_mutex& ) = delete; (2) (since C++14) 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_timed_mutex::try_lock

bool try_lock(); (since C++14) 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_timed_mutex::lock

void lock(); (since C++14) 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_timed_mutex::lock_shared

void lock_shared(); (since C++14) 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_ptr::swap

void swap( shared_ptr& r ); (since C++11) Exchanges the contents of *this and r. Parameters r - smart pointer to exchange the contents with Return value (none). Exceptions noexcept specification: noexcept

std::shared_ptr::shared_ptr

constexpr shared_ptr(); (1) template< class Y > explicit shared_ptr( Y* ptr ); (2) template< class Y, class Deleter > shared_ptr( Y* ptr, Deleter d ); (3) template< class Y, class Deleter, class Alloc > shared_ptr( Y* ptr, Deleter d, Alloc alloc ); (4) constexpr shared_ptr( std::nullptr_t ); (5) template< class Deleter > shared_ptr( std::nullptr_t, Deleter d ); (6) template< class Deleter, class Alloc > shared_ptr( std::nul

std::shared_ptr::unique

bool unique() const; Checks if *this is the only shared_ptr instance managing the current object, i.e. whether use_count() == 1. Parameters (none). Return value true if *this is the only shared_ptr instance managing the current object, false otherwise. Exceptions noexcept specification: noexcept Example #include <memory> #include <iostream> int main() { auto sp1 = std::make_shared<int>(5); std::cout << std::boolalpha; std::cout &

std::shared_ptr::use_count

long use_count() const; Returns the number of different shared_ptr instances (this included) managing the current object. If there is no managed object, ​0​ is returned. Parameters (none). Return value the number of shared_ptr instances managing the current object or ​0​ if there is no managed object. Exceptions noexcept specification: noexcept Example #include <memory> #include <iostream> void fun(std::shared_ptr<int> sp) { std::cout << "