Home | Trees | Indices | Help |
---|
|
object --+ | rw_lock
A many-reader single-writer lock.
This lock allows multiple "readers" to own the lock simultaneously. A "writer" can only acquire a lock if there are no other "readers" or "writers" holding the lock. Readers block when acquiring the lock if a writer currently holds it.
Readers and writers may acquire the lock multiple times, but they must release the lock an equal number of times.
A thread that holds a write lock may acquire read locks, but not the other way around (holding a read lock and trying to acquire a write lock will cause a deadlock).
|
|||
|
|||
a new object with type S, a subtype of T |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
_reader : Count of the number of read locks. |
|||
_waiting_readers : A fifo of coroutine objects waiting for a read lock. |
|||
_waiting_writers : A fifo of coroutine objects waiting for a write lock. |
|||
_writer : Count of the number of write locks. |
|||
_writer_id : Thread ID of the current write lock owner (0 if there is no owner). |
|
|||
Inherited from |
|
|
|
Acquire a read lock. Blocks if a writer owns the lock, or if any writers are waiting for the lock. An exception is if the writer that owns the lock is the current thread. A coro thread may acquire multiple read locks, but it must call read_unlock an equal number of times. |
Release a read lock. The thread unlocking must be the thread that initially locked it. |
Attempt to acquire a read lock. This is the same as read_lock except it does not block if it cannot acquire the lock.
|
Attempt to acquire a write lock. This is the same as write_lock except it does not block if it cannot acquire the lock.
|
Acquire a write lock. This blocks if there are any other readers or writers holding the lock. A coro thread may acquire multiple write locks, but it must call write_unlock an equal number of times. Attempting to acquire a read lock while holding a write lock will cause a deadlock. |
Release a write lock. The thread unlocking must be the thread that initially locked it. |
|
_reader: Count of the number of read locks. (C only.) |
_waiting_readers: A fifo of coroutine objects waiting for a read lock. (C only.) |
_waiting_writers: A fifo of coroutine objects waiting for a write lock. (C only.) |
_writer: Count of the number of write locks. (C only.) |
_writer_id: Thread ID of the current write lock owner (0 if there is no owner). (C only.) |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Feb 16 18:06:44 2012 | http://epydoc.sourceforge.net |