EtcPal
HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A wrapper class for the EtcPal read-write lock type.
Note: The etcpal::RwLock functions are not normally used directly - prefer usage of the RAII types etcpal::ReadGuard and etcpal::WriteGuard to manage locking and unlocking of an etcpal::RwLock.
Example usage:
See rwlock (Read-Write Locks) for more information.
Public Member Functions | |
RwLock () | |
Create a new read-write lock. | |
~RwLock () | |
Destroy the read-write lock. | |
RwLock (const RwLock &other)=delete | |
RwLock & | operator= (const RwLock &other)=delete |
RwLock (RwLock &&other)=delete | |
RwLock & | operator= (RwLock &&other)=delete |
bool | ReadLock () |
Access the read-write lock for reading. More... | |
bool | TryReadLock (int timeout_ms=0) |
Try to access the read-write lock for reading. More... | |
void | ReadUnlock () |
Release a read lock on the read-write lock. More... | |
bool | WriteLock () |
Access the read-write lock for writing. More... | |
bool | TryWriteLock (int timeout_ms=0) |
Try to access the read-write lock for writing. More... | |
void | WriteUnlock () |
Release a write lock on the read-write lock. More... | |
etcpal_rwlock_t & | get () |
Get a reference to the underlying etcpal_rwlock_t type. | |
|
inline |
Access the read-write lock for reading.
|
inline |
Release a read lock on the read-write lock.
|
inline |
Try to access the read-write lock for reading.
Returns when either the read lock is acquired or the timeout expires. NOTE: Timeout values other than 0 or ETCPAL_WAIT_FOREVER are typically only honored on real-time platforms. See the table in rwlock (Read-Write Locks) for more information. On platforms where timeouts are not honored, passing 0 for timeout_ms executes a poll for the lock returning immediately, while any other value executes the equivalent of ReadLock().
timeout_ms | How long to wait to acquire the read lock, in milliseconds. Default is to poll and return immediately. |
|
inline |
Try to access the read-write lock for writing.
Returns when either the read lock is acquired or the timeout expires. NOTE: Timeout values other than 0 or ETCPAL_WAIT_FOREVER are typically only honored on real-time platforms. See the table in rwlock (Read-Write Locks) for more information. On platforms where timeouts are not honored, passing 0 for timeout_ms executes a poll for the lock returning immediately, while any other value executes the equivalent of WriteLock().
timeout_ms | How long to wait to acquire the write lock, in milliseconds. Default is to poll and return immediately. |
|
inline |
Access the read-write lock for writing.
|
inline |
Release a write lock on the read-write lock.