Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Attributes
arcom.threadpool.ReadWriteLock Class Reference

List of all members.

Public Member Functions

def __init__
def acquire_read
def release_read
def acquire_write
def release_write

Private Attributes

 _read_ready
 _readers

Detailed Description

A lock object that allows many simultaneous "read locks", but
only one "write lock." 

Definition at line 177 of file threadpool.py.


Constructor & Destructor Documentation

Definition at line 181 of file threadpool.py.

00181 
00182     def __init__(self):
00183         self._read_ready = threading.Condition(threading.Lock())
00184         self._readers = 0


Member Function Documentation

Acquire a read lock. Blocks only if a thread has
acquired the write lock. 

Definition at line 185 of file threadpool.py.

00185 
00186     def acquire_read(self):
00187         """ Acquire a read lock. Blocks only if a thread has
00188         acquired the write lock. """
00189         self._read_ready.acquire()
00190         try:
00191             self._readers += 1
00192         finally:
00193             self._read_ready.release()

Acquire a write lock. Blocks until there are no
acquired read or write locks. 

Definition at line 204 of file threadpool.py.

00204 
00205     def acquire_write(self):
00206         """ Acquire a write lock. Blocks until there are no
00207         acquired read or write locks. """
00208         self._read_ready.acquire()
00209         while self._readers > 0:
00210             self._read_ready.wait()

Release a read lock. 

Definition at line 194 of file threadpool.py.

00194 
00195     def release_read(self):
00196         """ Release a read lock. """
00197         self._read_ready.acquire()
00198         try:
00199             self._readers -= 1
00200             if not self._readers:
00201                 self._read_ready.notifyAll()
00202         finally:
00203             self._read_ready.release()

Release a write lock. 

Definition at line 211 of file threadpool.py.

00211 
00212     def release_write(self):    
00213         """ Release a write lock. """
00214         self._read_ready.release()


Member Data Documentation

Definition at line 182 of file threadpool.py.

Definition at line 183 of file threadpool.py.


The documentation for this class was generated from the following file: