Raw operating-system-thread lock wrapper with exclusive and shared acquisition. The wrapper owns one lock state and exposes direct lock operations.
Mutex
Methods
INIT |
(--) |
Resets the mutex to the unlocked initial state. |
lock |
(--) |
Acquires one exclusive lock ownership. |
lockShared |
(--) |
Acquires one shared lock ownership. |
tryLock |
(-- locked) |
Attempts one exclusive acquisition without waiting. Returns TRUE when the acquisition is made and FALSE otherwise. |
tryLockShared |
(-- locked) |
Attempts one shared acquisition without waiting. Returns TRUE when the acquisition is made and FALSE otherwise. |
unlock |
(--) |
Releases one exclusive acquisition. |
Preconditions
- The current thread holds one exclusive acquisition of this mutex.
Preconditions
- The current thread holds one shared acquisition of this mutex.
Remarks
- A newly constructed
Mutex starts unlocked.
Lock semantics
lock and unlock operate on exclusive ownership.
lockShared and unlockShared operate on shared ownership.
- Each successful lock operation represents one acquisition. Each matching unlock operation releases one acquisition.
- No separate lock token object is created by the mutex.
tryLock and tryLockShared never wait and report only immediate success or failure.
- The mutex owns one lock state. Scope-based balancing can be built around that same state.