An optimized and convertable shared lock.
More...
#include <thread.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.
|
void | exclusive (void) |
| Convert read lock into exclusive (write/modify) access.
|
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.
|
void | modify (void) |
| Acquire write (exclusive modify) lock.
|
void | release (void) |
| Release a shared lock.
|
void | share (void) |
| Return an exclusive access lock back to share mode.
|
| ~ConditionalLock () |
| Destroy conditional lock.
|
Static Public Member Functions |
static void | access (ConditionalLock &lock) |
| Convenience function to aqcuire a shared lock.
|
static void | commit (ConditionalLock &lock) |
| Convenience function to commit a modify lock.
|
static void | exclusive (ConditionalLock &lock) |
| Convenience function to convert lock to exclusive mode.
|
static void | modify (ConditionalLock &lock) |
| Convenience function to modify lock.
|
static void | release (ConditionalLock &lock) |
| Convenience function to release a shared lock.
|
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 792 of file thread.h.
Member Function Documentation
static void ucc::ConditionalLock::access |
( |
ConditionalLock & |
lock |
) |
[inline, static] |
Convenience function to aqcuire a shared lock.
- Parameters:
-
Definition at line 889 of file thread.h.
static void ucc::ConditionalLock::commit |
( |
ConditionalLock & |
lock |
) |
[inline, static] |
Convenience function to commit a modify lock.
- Parameters:
-
Definition at line 875 of file thread.h.
void ucc::ConditionalLock::exclusive |
( |
void |
|
) |
|
Convert read lock into exclusive (write/modify) access.
Schedule when other readers sharing.
static void ucc::ConditionalLock::exclusive |
( |
ConditionalLock & |
lock |
) |
[inline, static] |
Convenience function to convert lock to exclusive mode.
- Parameters:
-
Definition at line 896 of file thread.h.
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 868 of file thread.h.
static void ucc::ConditionalLock::release |
( |
ConditionalLock & |
lock |
) |
[inline, static] |
Convenience function to release a shared lock.
- Parameters:
-
Definition at line 882 of file thread.h.
static void ucc::ConditionalLock::share |
( |
ConditionalLock & |
lock |
) |
[inline, static] |
Convenience function to convert lock to shared access.
- Parameters:
-
Definition at line 903 of file thread.h.
The documentation for this class was generated from the following file: