ucc::rwlock Class Reference
A generic and portable implimentation of Read/Write locking.
More...
#include <thread.h>
Detailed Description
A generic and portable implimentation of Read/Write locking.
This class impliments classical read/write locking, including "timed" locks. Support for scheduling threads to avoid writer starvation is also provided for. By building read/write locks from a conditional, we make them available on pthread implimetations and other platforms which do not normally include optional pthread rwlock's. We also do not restrict the number of threads that may use the lock. Finally, both the exclusive and shared protocols are implimented to support exclusive_lock and shared_lock referencing.
- Author:
- David Sugar <dyfet@gnutelephony.org>
Definition at line 517 of file thread.h.
Member Function Documentation
Convenience function to access (read lock) a rwlock.
- Parameters:
-
| lock | to access. |
| timeout | to wait for lock. |
- Returns:
- true if successful, false if timeout.
Definition at line 719 of file thread.h.
Request shared (read) access through the lock.
- Parameters:
-
| timeout | in milliseconds to wait for lock. |
- Returns:
- true if locked, false if timeout.
unsigned ucc::rwlock::getAccess |
( |
void |
|
) |
|
Get the number of threads in shared access mode.
- Returns:
- number of accessing threads.
unsigned ucc::rwlock::getModify |
( |
void |
|
) |
|
Get the number of threads waiting to modify the lock.
- Returns:
- number of pending write threads.
unsigned ucc::rwlock::getWaiting |
( |
void |
|
) |
|
Get the number of threads waiting to access after writer completes.
- Returns:
- number of waiting access threads.
static void ucc::rwlock::indexing |
( |
unsigned |
size |
) |
[static] |
Specify hash table size for gaurd protection.
The default is 1. This should be called at initialization time from the main thread of the application before any other threads are created.
- Parameters:
-
| size | of hash table used for gaurding. |
Convenience function to modify (write lock) a rwlock.
- Parameters:
-
| lock | to modify. |
| timeout | to wait for lock. |
- Returns:
- true if successful, false if timeout.
Definition at line 710 of file thread.h.
Request modify (write) access through the lock.
- Parameters:
-
| timeout | in milliseconds to wait for lock. |
- Returns:
- true if locked, false if timeout.
Shared access to an arbitrary object.
This is based on the protect function of mutex.
- Parameters:
-
| object | to share. |
| timeout | in milliseconds to wait for lock. |
- Returns:
- true if shared, false if timeout.
static void ucc::rwlock::release |
( |
rwlock & |
lock |
) |
[inline, static] |
Convenience function to release a rwlock.
- Parameters:
-
Definition at line 726 of file thread.h.
static void ucc::rwlock::release |
( |
void * |
object |
) |
[static] |
Release an arbitrary object that has been protected by a rwlock.
- Parameters:
-
Write protect access to an arbitrary object.
This is like the protect function of mutex.
- Parameters:
-
| object | to protect. |
| timeout | in milliseconds to wait for lock. |
- Returns:
- true if locked, false if timeout.
The documentation for this class was generated from the following file: