class documentation

class ReadWriteLock(object):

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):

Initialize the ReadWriteLock object.

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

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

def acquire_write(self):

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

def release_read(self):

Release a read lock.

def release_write(self):

Release a write lock.

_promote =

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

_read_ready =

Condition object to synchronize the read and write locks.

_readerList: list[int] =

List of Reader thread IDs.

_readers: int =

Number of readers.

_writerList: list[int] =

List of Writer thread IDs.

_writers: int =

Number of writers.