|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Exclusive locking | ||||
shared_mutex::try_lock | ||||
| Shared locking | ||||
| Native handle | ||||
bool try_lock(); | (since C++17) | |
Tries to lock the mutex. Returns immediately. On successful lock acquisition returnstrue, otherwise returnsfalse.
This function is allowed to fail spuriously and returnfalse even if the mutex is not currently locked by any other thread.
Iftry_lock is called by a thread that already owns themutex in any mode (shared or exclusive), the behavior is undefined.
Priorunlock() operation on the same mutexsynchronizes-with (as defined instd::memory_order) this operation if it returnstrue. Note that priorlock() does not synchronize with this operation if it returnsfalse.
Contents |
(none)
true if the lock was acquired successfully, otherwisefalse.
Throws nothing.
| This section is incomplete Reason: no example |
| locks the mutex, blocks if the mutex is not available (public member function)[edit] | |
| unlocks the mutex (public member function)[edit] | |
C documentation formtx_trylock | |