Class LockMRSW

  • All Implemented Interfaces:
    Lock

    public class LockMRSW
    extends java.lang.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
      • Field Summary

        • Fields inherited from interface org.apache.jena.shared.Lock

          READ, WRITE
      • Constructor Summary

        Constructors 
        Constructor Description
        LockMRSW()  
      • Method Summary

        All Methods Instance Methods Concrete Methods 
        Modifier and Type Method Description
        void enterCriticalSection​(boolean readLockRequested)
        Application controlled locking - enter a critical section.
        void leaveCriticalSection()
        Application controlled locking - leave a critical section.
        • Methods inherited from class java.lang.Object

          equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Constructor Detail

        • LockMRSW

          public LockMRSW()
      • Method Detail

        • 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
          Parameters:
          readLockRequested - true implies a read lock, false implies write lock.
          See Also:
          Lock.leaveCriticalSection()