|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
A simple RAII type that owns a lock. More...
#include <locks.hh>
Public Member Functions | |
| LockGuard (Lock &lock) | |
| Constructor, acquires the lock with unbounded wait. | |
| LockGuard (Lock &lock, TimeoutArgument timeout) | |
| Constructor, attempts to acquire the lock with a timeout. | |
| LockGuard (LockGuard &&guard) | |
| Move constructor, transfers ownership of the lock. | |
| void | lock () |
| Explicitly lock the wrapped lock. | |
| void | unlock () |
| Explicitly lock the wrapped lock. | |
| void | release () |
| Unwrap the lock without unlocking it. | |
| bool | try_lock (TimeoutArgument timeout) |
| If the wrapped lock type supports locking with a timeout, try to lock it with the specified timeout. | |
| ~LockGuard () | |
| Destructor, releases the lock. | |
| operator bool () | |
| Conversion to bool. | |
| int | yield (TimeoutArgument t, uint32_t ticks=1) |
| Drop and reacquire the lock around a yield. | |
A simple RAII type that owns a lock.
|
inlineexplicitnodiscard |
Constructor, acquires the lock with unbounded wait.
The lock to be wrapped must not be held by the calling thread on entry. Further, for this constructor to be safe to invoke, the Lock type must have an unfailable lock member; for example, this precludes the use of FlagLock-s that may be placed in "destruction mode".
In general, prefer the LockGuard constructor that takes a Timeout.
Definition at line 317 of file locks.hh.
References lock().
Referenced by LockGuard().
|
inlineexplicitnodiscard |
Constructor, attempts to acquire the lock with a timeout.
The lock to be wrapped must not be held by the calling thread on entry.
Definition at line 328 of file locks.hh.
References lock(), and try_lock().
|
inlineexplicitnodiscard |
Move constructor, transfers ownership of the lock.
Definition at line 336 of file locks.hh.
References LockGuard().
|
inline |
Explicitly lock the wrapped lock.
The wrapped lock must not be held by the calling thread on entry. For this method to be safe to call, the Lock type must have an unfailable lock member; for example, this precludes the use of FlagLock-s that may be placed in "destruction mode". In general, prefer try_lock.
Definition at line 353 of file locks.hh.
Referenced by LockGuard(), and LockGuard().
|
inline |
Conversion to bool.
Returns true if this guard owns the lock, false otherwise. This allows lock guards to be used with a timeout in conditional blocks, such as:
|
inline |
|
inline |
If the wrapped lock type supports locking with a timeout, try to lock it with the specified timeout.
The wrapped lock must not be held by the calling thread on entry. Returns true if the lock has been acquired, false otherwise.
Definition at line 388 of file locks.hh.
Referenced by LockGuard(), and yield().
|
inline |
|
inline |
Drop and reacquire the lock around a yield.
Definition at line 430 of file locks.hh.
References thread_sleep(), try_lock(), and unlock().