Namespaces
Variants
Views
Actions

std::shared_lock

From cppreference.com
 
 
Thread support library
Threads
thread(C++11)
this_thread namespace
get_id(C++11)
yield(C++11)
sleep_for(C++11)
sleep_until(C++11)
Mutual exclusion
mutex(C++11)
timed_mutex(C++11)
Generic lock management
lock_guard(C++11)
unique_lock(C++11)
shared_lock(C++14)
defer_lock_t
try_to_lock_t
adopt_lock_t
(C++11)
(C++11)
(C++11)
lock(C++11)
try_lock(C++11)
defer_lock
try_to_lock
adopt_lock
(C++11)
(C++11)
(C++11)
Condition variables
condition_variable(C++11)
condition_variable_any(C++11)
notify_all_at_thread_exit(C++11)
cv_status(C++11)
Futures
promise(C++11)
future(C++11)
shared_future(C++11)
packaged_task(C++11)
async(C++11)
launch(C++11)
future_status(C++11)
future_error(C++11)
future_category(C++11)
future_errc(C++11)
 
 
Defined in header <mutex>
template< class Mutex >
class shared_lock;
(since C++14)

The class shared_lock is a general-purpose shared mutex ownership wrapper allowing deferred locking, timed locking and transfer of lock ownership,

The shared_lock class is movable, but not copyable -- it meets the requirements of MoveConstructible and MoveAssignable but not of CopyConstructible or CopyAssignable.

Contents

[edit] Template parameters

Mutex - the type of the shared mutex to lock. The type must meet the SharedMutex requirements

[edit] Member types

Type Definition
mutex_type Mutex

[edit] Member functions

Template:cpp/thread/shared lock/dsc constructorTemplate:cpp/thread/shared lock/dsc destructorTemplate:cpp/thread/shared lock/dsc operator=Template:cpp/thread/shared lock/dsc lockTemplate:cpp/thread/shared lock/dsc try lockTemplate:cpp/thread/shared lock/dsc try lock forTemplate:cpp/thread/shared lock/dsc try lock untilTemplate:cpp/thread/shared lock/dsc unlockTemplate:cpp/thread/shared lock/dsc swapTemplate:cpp/thread/shared lock/dsc releaseTemplate:cpp/thread/shared lock/dsc mutexTemplate:cpp/thread/shared lock/dsc owns lockTemplate:cpp/thread/shared lock/dsc operator bool
Shared locking
Modifiers
Observers

[edit] Non-member functions

specialization of std::swap for shared_lock
(function template) [edit]