Class LockMRSW

All Implemented Interfaces:

public class LockMRSW extends Object implements Lock
Lock implementation using a Multiple Reader, Single Writer policy. All the locking work is done by the imported WriterPreferenceReadWriteLock. This class adds:
  • The same thread that acquired a lock should release it
  • Lock promotion (turning read locks into write locks) is detached as an error
  • Constructor Details

    • LockMRSW

      public LockMRSW()
  • Method Details

    • enterCriticalSection

      public final void enterCriticalSection(boolean readLockRequested)
      Application controlled locking - enter a critical section. Locking is reentrant so an application can have nested critical sections. Typical code:
        try {
           enterCriticalSection(Lock.READ) ;
           ... application code ...
        } finally { leaveCriticalSection() ; }
      Specified by:
      enterCriticalSection in interface Lock
      readLockRequested - true implies a read lock, false implies write lock.
      See Also:
    • leaveCriticalSection

      public final void leaveCriticalSection()
      Application controlled locking - leave a critical section.
      Specified by:
      leaveCriticalSection in interface Lock
      See Also: