在线文档教程

SharedMutex

C++ concepts: SharedMutex

The SharedMutex concept extends the Mutex concept to include shared lock ownership mode.

Requirements

  • Mutex

Additionally, for object m of SharedMutex type supports another mode of ownership: shared. Multiple threads (or, more generally, execution agents) can simulataneously own this mutex in shared mode, but no thread may obtain shared ownership if there is a thread that owns it in exclusive mode and no thread may obtain exclusive ownership if there is a thread that owns it in shared mode. If more than implementation-defined number of threads (no less than 10000) hold a shared lock, another attempt to acquire the mutex in shared mode blocks until the number of shared owners drops down below that threshold.

  • The expression m.lock_shared() has the following properties

Library types

The following standard library types satisfy SharedMutex:

  • std::shared_mutex(since C++17)

See also

  • Thread support library

© cppreference.com

Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.

http://en.cppreference.com/w/cpp/concept/SharedMutex