VIBE v5.1.6
Search Engine
Loading...
Searching...
No Matches
edu.usfca.cs272.MultiReaderLock Class Reference

Classes

interface  SimpleLock
 

Public Member Functions

 MultiReaderLock ()
 
SimpleLock readLock ()
 
SimpleLock writeLock ()
 
int readers ()
 
int writers ()
 
boolean isActiveWriter ()
 

Detailed Description

Maintains a pair of associated locks, one for read-only operations and one for writing. The read lock may be held simultaneously by multiple reader threads, so long as there are no writers. The write lock is exclusive. The active writer is able to acquire read or write locks as long as it is active.

See also
SimpleLock
Lock
ReentrantLock
ReadWriteLock
ReentrantReadWriteLock
Author
CS 272 Software Development (University of San Francisco)
Ravneet Singh Bhatia
Version
Spring 2024

Constructor & Destructor Documentation

◆ MultiReaderLock()

edu.usfca.cs272.MultiReaderLock.MultiReaderLock ( )

Initializes a new simple read/write lock.

Member Function Documentation

◆ isActiveWriter()

boolean edu.usfca.cs272.MultiReaderLock.isActiveWriter ( )

Determines whether the thread running this code and the writer thread are in fact the same thread.

Returns
true if the thread running this code and the writer thread are not null and are the same thread
See also
Thread::currentThread()

◆ readers()

int edu.usfca.cs272.MultiReaderLock.readers ( )

Returns the number of active readers.

Returns
the number of active readers

◆ readLock()

SimpleLock edu.usfca.cs272.MultiReaderLock.readLock ( )

Returns the reader lock.

Returns
the reader lock

◆ writeLock()

SimpleLock edu.usfca.cs272.MultiReaderLock.writeLock ( )

Returns the writer lock.

Returns
the writer lock

◆ writers()

int edu.usfca.cs272.MultiReaderLock.writers ( )

Returns the number of active writers.

Returns
the number of active writers

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