UCommon
Public Member Functions | Protected Member Functions | Protected Attributes
ucommon::ConditionalLock Class Reference

An optimized and convertable shared lock. More...

#include <thread.h>

Inheritance diagram for ucommon::ConditionalLock:
Inheritance graph
[legend]
Collaboration diagram for ucommon::ConditionalLock:
Collaboration graph
[legend]

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. More...
 
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.
 
- Public Member Functions inherited from ucommon::SharedAccess
void release_share (void)
 
void shared_lock (void)
 

Protected Member Functions

virtual void _share (void)
 Access interface to share lock the object.
 
virtual void _unlock (void)
 
Context * getContext (void)
 
- Protected Member Functions inherited from ucommon::ConditionalAccess
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. More...
 
void modify (void)
 Exclusive mode write thread scheduling.
 
void release (void)
 Release access mode read scheduling.
 
 ~ConditionalAccess ()
 Destroy conditional, release any blocked threads.
 
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 (timeout_t timeout)
 Conditional wait for broadcast on millisecond timeout. More...
 
bool waitBroadcast (struct timespec *timeout)
 Conditional wait for broadcast on timespec timeout. More...
 
void waitBroadcast (void)
 Wait (block) until broadcast.
 
bool waitSignal (timeout_t timeout)
 Conditional wait for signal on millisecond timeout. More...
 
bool waitSignal (struct timespec *timeout)
 Conditional wait for signal on timespec timeout. More...
 
void waitSignal (void)
 Wait (block) until signalled.
 

Protected Attributes

LinkedObjectcontexts
 

Additional Inherited Members

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 714 of file thread.h.

Member Function Documentation

virtual void ucommon::ConditionalLock::exclusive ( void  )
virtual

Convert read lock into exclusive (write/modify) access.

Schedule when other readers sharing.

Reimplemented from ucommon::SharedAccess.


The documentation for this class was generated from the following file: