Package concurrent_tree_crawler :: Package common :: Package threads :: Module rw_lock :: Class RWLock
[hide private]
[frames] | no frames]

Class RWLock

source code

Synchronization object used in a solution of so-called second readers-writers problem. In this problem, many readers can simultaneously access a share, and a writer has an exclusive access to this share. Additionally, the following constraints should be met:

The implementation is based on [1, secs. 4.2.2, 4.2.6, 4.2.7] with a modification -- adding an additional lock (self.__readers_queue) -- in accordance with [2].

Sources:

  1. A.B. Downey: "The little book of semaphores", Version 2.1.5, 2008
  2. P.J. Courtois, F. Heymans, D.L. Parnas: "Concurrent Control with 'Readers' and 'Writers'", Communications of the ACM, 1971 (via [3])
  3. http://en.wikipedia.org/wiki/Readers-writers_problem
Instance Methods [hide private]
 
__init__(self) source code
 
reader_acquire(self) source code
 
reader_release(self) source code
 
writer_acquire(self) source code
 
writer_release(self) source code
Instance Variables [hide private]
  __readers_queue
A lock giving an even higher priority to the writer in certain cases (see [2] for a discussion)