UCommon
ucommon::ConditionalLock Class Reference

An optimized and convertable shared lock. More...

#include <condition.h>

Inheritance diagram for ucommon::ConditionalLock:
Collaboration diagram for ucommon::ConditionalLock:

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)
 
- Protected Member Functions inherited from ucommon::ConditionalAccess
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

LinkedObjectcontexts
 
- Protected Attributes inherited from ucommon::ConditionalAccess
pthread_cond_t bcast
 
unsigned pending
 
unsigned sharing
 
unsigned waiting
 

Additional Inherited Members

- Static Protected Member Functions inherited from ucommon::ConditionalAccess
static void set (struct timespec *hires, timeout_t timeout)
 Convert a millisecond timeout into use for high resolution conditional timers.
 
- Static Protected Attributes inherited from ucommon::ConditionalAccess
static unsigned max_sharing
 

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 508 of file condition.h.

Member Function Documentation

◆ _share()

virtual void ucommon::ConditionalLock::_share ( void )
protectedvirtual

Access interface to share lock the object.

Implements ucommon::SharedProtocol.

◆ _unshare()

virtual void ucommon::ConditionalLock::_unshare ( void )
protectedvirtual

◆ exclusive()

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

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

Schedule when other readers sharing.

Reimplemented from ucommon::SharedProtocol.

◆ share()

virtual void ucommon::ConditionalLock::share ( void )
virtual

Return an exclusive access lock back to share mode.

Reimplemented from ucommon::SharedProtocol.

Field Documentation

◆ contexts

LinkedObject* ucommon::ConditionalLock::contexts
protected

Definition at line 526 of file condition.h.


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