#include <thread.h>
Public Member Functions | |
bool | access (timeout_t timeout=Timer::inf) |
Request shared (read) access through the lock. | |
unsigned | getAccess (void) |
Get the number of threads in shared access mode. | |
unsigned | getModify (void) |
Get the number of threads waiting to modify the lock. | |
unsigned | getWaiting (void) |
Get the number of threads waiting to access after writer completes. | |
bool | modify (timeout_t timeout=Timer::inf) |
Request modify (write) access through the lock. | |
void | release (void) |
Release the lock. | |
rwlock () | |
Create an instance of a rwlock. | |
Static Public Member Functions | |
static bool | access (rwlock &lock, timeout_t timeout=Timer::inf) |
Convenience function to access (read lock) a rwlock. | |
static void | indexing (unsigned size) |
Specify hash table size for gaurd protection. | |
static bool | modify (rwlock &lock, timeout_t timeout=Timer::inf) |
Convenience function to modify (write lock) a rwlock. | |
static bool | reader (void *object, timeout_t timeout=Timer::inf) |
Shared access to an arbitrary object. | |
static void | release (rwlock &lock) |
Convenience function to release a rwlock. | |
static void | release (void *object) |
Release an arbitrary object that has been protected by a rwlock. | |
static bool | writer (void *object, timeout_t timeout=Timer::inf) |
Write protect access to an arbitrary object. | |
Data Structures | |
class | gaurd_reader |
Gaurd class to apply scope based access locking to objects. More... | |
class | gaurd_writer |
Gaurd class to apply scope based exclusive locking to objects. More... |
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.
Definition at line 543 of file thread.h.
static bool ucc::rwlock::access | ( | rwlock & | lock, | |
timeout_t | timeout = Timer::inf | |||
) | [inline, static] |
bool ucc::rwlock::access | ( | timeout_t | timeout = Timer::inf |
) |
Request shared (read) access through the lock.
timeout | in milliseconds to wait for lock. |
unsigned ucc::rwlock::getAccess | ( | void | ) |
Get the number of threads in shared access mode.
unsigned ucc::rwlock::getModify | ( | void | ) |
Get the number of threads waiting to modify the lock.
unsigned ucc::rwlock::getWaiting | ( | void | ) |
Get the number of threads waiting to access after writer completes.
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.
size | of hash table used for gaurding. |
static bool ucc::rwlock::modify | ( | rwlock & | lock, | |
timeout_t | timeout = Timer::inf | |||
) | [inline, static] |
bool ucc::rwlock::modify | ( | timeout_t | timeout = Timer::inf |
) |
Request modify (write) access through the lock.
timeout | in milliseconds to wait for lock. |
static bool ucc::rwlock::reader | ( | void * | object, | |
timeout_t | timeout = Timer::inf | |||
) | [static] |
static void ucc::rwlock::release | ( | rwlock & | lock | ) | [inline, static] |
static void ucc::rwlock::release | ( | void * | object | ) | [static] |
static bool ucc::rwlock::writer | ( | void * | object, | |
timeout_t | timeout = Timer::inf | |||
) | [static] |
Write protect access to an arbitrary object.
This is like the protect function of mutex.
object | to protect. | |
timeout | in milliseconds to wait for lock. |