class documentation

class ReadWriteLock(object): (source)

Constructor: ReadWriteLock(withPromotion)

View In Hierarchy

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

Method __init__ Initialize the ReadWriteLock object.
Method acquire_read Acquire a read lock. Blocks only if a thread has acquired the write lock.
Method acquire_write Acquire a write lock. Blocks until there are no acquired read or write locks.
Method release_read Release a read lock.
Method release_write Release a write lock.
Instance Variable _promote If True, then a reader thread can promote itself to a writer thread.
Instance Variable _read_ready Condition object to synchronize the read and write locks.
Instance Variable _readerList List of Reader thread IDs.
Instance Variable _readers Number of readers.
Instance Variable _writerList List of Writer thread IDs.
Instance Variable _writers Number of writers.
def __init__(self, withPromotion: bool | None = False): (source)

Initialize the ReadWriteLock object.

Parameters
withPromotion:bool | NoneIf True, then a reader thread can promote itself to a writer thread.
def acquire_read(self): (source)

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

def acquire_write(self): (source)

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

def release_read(self): (source)

Release a read lock.

def release_write(self): (source)

Release a write lock.

_promote = (source)

If True, then a reader thread can promote itself to a writer thread.

_read_ready = (source)

Condition object to synchronize the read and write locks.

_readerList: list[int] = (source)

List of Reader thread IDs.

_readers: int = (source)

Number of readers.

_writerList: list[int] = (source)

List of Writer thread IDs.

_writers: int = (source)

Number of writers.