Ion
|
A TryLockGuard attempts to lock a mutex when created, and if successful, will unlock it when destroyed. More...
#include "lockguards.h"
Public Member Functions | |
GenericTryLockGuard (MutexT *m) | |
The passed pointer must be non-NULL. More... | |
bool | IsLocked () const |
Returns whether this guard has locked the mutex; returns false even if another guard has it locked. More... | |
void | Lock () |
Locks the mutex if it is not already locked by this guard. More... | |
bool | TryLock () |
Attempts to lock the mutex if the mutex is not already locked by this guard. More... | |
void | Unlock () |
Releases a lock on the mutex if it was previously locked by this guard. More... | |
Protected Attributes | |
MutexT & | mutex_ |
The mutex used for locking. More... | |
bool | is_locked_ |
Whether the mutex is currently locked by this guard. More... | |
A TryLockGuard attempts to lock a mutex when created, and if successful, will unlock it when destroyed.
Use IsLocked() to determine if the initial lock was successful. A TryLockGuard never blocks.
Definition at line 106 of file lockguards.h.
|
inlineexplicit |
The passed pointer must be non-NULL.
Definition at line 109 of file lockguards.h.
|
inlineinherited |
Returns whether this guard has locked the mutex; returns false even if another guard has it locked.
Use MutexT::IsLocked() to determine if the mutex itself is locked.
Definition at line 40 of file lockguards.h.
|
inlineinherited |
Locks the mutex if it is not already locked by this guard.
This function blocks if the mutex is locked elsewhere (e.g., by another guard).
Definition at line 44 of file lockguards.h.
|
inlineinherited |
Attempts to lock the mutex if the mutex is not already locked by this guard.
This function never blocks. Returns true if the mutex was successfully locked or if this guard has already locked it, and false otherwise.
Definition at line 55 of file lockguards.h.
|
inlineinherited |
Releases a lock on the mutex if it was previously locked by this guard.
Definition at line 63 of file lockguards.h.
|
protectedinherited |
Whether the mutex is currently locked by this guard.
Definition at line 81 of file lockguards.h.
|
protectedinherited |
The mutex used for locking.
Definition at line 79 of file lockguards.h.