hpx/synchronization/shared_mutex.hpp#

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx

Typedefs

using shared_mutex = detail::shared_mutex<>#

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.

If one thread has acquired the exclusive lock (through lock, try_lock), no other threads can acquire the lock (including the shared). If one thread has acquired the shared lock (through lock_shared, try_lock_shared), no other thread can acquire the exclusive lock, but can acquire the shared lock. Only when the exclusive lock has not been acquired by any thread, the shared lock can be acquired by multiple threads. Within one thread, only one lock (shared or exclusive) can be acquired at the same time. Shared mutexes are especially useful when shared data can be safely read by any number of threads simultaneously, but a thread may only write the same data when no other thread is reading or writing at the same time. The shared_mutex class satisfies all requirements of SharedMutex and StandardLayoutType.

namespace lcos
namespace local