ucc::ConditionalLock Class Reference

An optimized and convertable shared lock. More...

#include <thread.h>

Inheritance diagram for ucc::ConditionalLock:

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

Collaboration graph
[legend]

Public Member Functions

 ConditionalLock ()
 Construct conditional lock for default concurrency.
 ~ConditionalLock ()
 Destroy conditional lock.
void modify (void)
 Acquire write (exclusive modify) lock.
void commit (void)
 Commit changes / release a modify lock.
void access (void)
 Acquire access (shared read) lock.
void release (void)
 Release a shared lock.
void exclusive (void)
 Convert read lock into exclusive (write/modify) access.
void share (void)
 Return an exclusive access lock back to share mode.
unsigned getReaders (void)
 Get the number of threads reading (sharing) the lock.
unsigned getWaiters (void)
 Get the number of threads waiting to share the lock.

Static Public Member Functions

static void modify (ConditionalLock &lock)
 Convenience function to modify lock.
static void commit (ConditionalLock &lock)
 Convenience function to commit a modify lock.
static void release (ConditionalLock &lock)
 Convenience function to release a shared lock.
static void access (ConditionalLock &lock)
 Convenience function to aqcuire a shared lock.
static void exclusive (ConditionalLock &lock)
 Convenience function to convert lock to exclusive mode.
static void share (ConditionalLock &lock)
 Convenience function to convert lock to shared access.

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@gnutelephony.org>

Definition at line 776 of file thread.h.


Member Function Documentation

static void ucc::ConditionalLock::access ( ConditionalLock lock  )  [inline, static]

Convenience function to aqcuire a shared lock.

Parameters:
lock to share.

Definition at line 873 of file thread.h.

Here is the call graph for this function:

static void ucc::ConditionalLock::commit ( ConditionalLock lock  )  [inline, static]

Convenience function to commit a modify lock.

Parameters:
lock to commit.

Definition at line 859 of file thread.h.

Here is the call graph for this function:

static void ucc::ConditionalLock::exclusive ( ConditionalLock lock  )  [inline, static]

Convenience function to convert lock to exclusive mode.

Parameters:
lock to convert.

Definition at line 880 of file thread.h.

Here is the call graph for this function:

void ucc::ConditionalLock::exclusive ( void   ) 

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

Schedule when other readers sharing.

static void ucc::ConditionalLock::modify ( ConditionalLock lock  )  [inline, static]

Convenience function to modify lock.

Parameters:
lock to acquire in write exclusive mode.

Definition at line 852 of file thread.h.

Here is the call graph for this function:

static void ucc::ConditionalLock::release ( ConditionalLock lock  )  [inline, static]

Convenience function to release a shared lock.

Parameters:
lock to release.

Definition at line 866 of file thread.h.

Here is the call graph for this function:

static void ucc::ConditionalLock::share ( ConditionalLock lock  )  [inline, static]

Convenience function to convert lock to shared access.

Parameters:
lock to convert.

Definition at line 887 of file thread.h.

Here is the call graph for this function:


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

Generated on Wed May 13 08:43:22 2009 for UCommon by  doxygen 1.5.7.1