UCommon
|
An optimized and convertable shared lock. More...
#include <condition.h>
Public Member Functions | |
void | access (void) |
Acquire access (shared read) lock. | |
void | commit (void) |
Commit changes / release a modify lock. | |
ConditionalLock () | |
Construct conditional lock for default concurrency. | |
virtual void | exclusive (void) |
Convert read lock into exclusive (write/modify) access. | |
void | modify (void) |
Acquire write (exclusive modify) lock. | |
void | release (void) |
Release a shared lock. | |
virtual void | share (void) |
Return an exclusive access lock back to share mode. | |
~ConditionalLock () | |
Destroy conditional lock. | |
Protected Member Functions | |
virtual void | _share (void) |
Access interface to share lock the object. | |
virtual void | _unshare (void) |
Context * | getContext (void) |
![]() | |
void | broadcast (void) |
Signal the conditional to release all broadcast threads. | |
void | lock (void) |
Lock the conditional's supporting mutex. | |
void | signal (void) |
Signal the conditional to release one signalled thread. | |
void | unlock (void) |
Unlock the conditional's supporting mutex. | |
bool | waitBroadcast (struct timespec *timeout) |
Conditional wait for broadcast on timespec timeout. | |
bool | waitBroadcast (timeout_t timeout) |
Conditional wait for broadcast on millisecond timeout. | |
void | waitBroadcast (void) |
Wait (block) until broadcast. | |
bool | waitSignal (struct timespec *timeout) |
Conditional wait for signal on timespec timeout. | |
bool | waitSignal (timeout_t timeout) |
Conditional wait for signal on millisecond timeout. | |
void | waitSignal (void) |
Wait (block) until signalled. | |
void | access (void) |
Access mode shared thread scheduling. | |
void | commit (void) |
Complete exclusive mode write scheduling. | |
ConditionalAccess () | |
Initialize and construct conditional. | |
void | limit_sharing (unsigned max) |
Specify a maximum sharing (access) limit. | |
void | modify (void) |
Exclusive mode write thread scheduling. | |
void | release (void) |
Release access mode read scheduling. | |
~ConditionalAccess () | |
Destroy conditional, release any blocked threads. | |
Protected Attributes | |
LinkedObject * | contexts |
![]() | |
pthread_cond_t | bcast |
unsigned | pending |
unsigned | sharing |
unsigned | waiting |
Additional Inherited Members | |
![]() | |
static void | set (struct timespec *hires, timeout_t timeout) |
Convert a millisecond timeout into use for high resolution conditional timers. | |
![]() | |
static unsigned | max_sharing |
An optimized and convertable shared lock.
This is a form of read/write lock that has been optimized, particularly for shared access. Support for scheduling access around writer starvation is also included. The other benefits over traditional read/write locks is that the code is a little lighter, and read (shared) locks can be converted to exclusive (write) locks to perform brief modify operations and then returned to read locks, rather than having to release and re-aquire locks to change mode.
Definition at line 508 of file condition.h.
|
protectedvirtual |
Access interface to share lock the object.
Implements ucommon::SharedProtocol.
|
protectedvirtual |
Implements ucommon::SharedProtocol.
|
virtual |
Convert read lock into exclusive (write/modify) access.
Schedule when other readers sharing.
Reimplemented from ucommon::SharedProtocol.
|
virtual |
Return an exclusive access lock back to share mode.
Reimplemented from ucommon::SharedProtocol.
|
protected |
Definition at line 526 of file condition.h.