Class ReentrantWrappedStampedLock

java.lang.Object
com.fastasyncworldedit.core.concurrent.ReentrantWrappedStampedLock
All Implemented Interfaces:
Lock

public class ReentrantWrappedStampedLock extends Object implements Lock
Allows for reentrant behaviour of a wrapped StampedLock. Will not count the number of times it is re-entered.
Since:
2.3.0
  • Constructor Details

    • ReentrantWrappedStampedLock

      public ReentrantWrappedStampedLock()
  • Method Details

    • lock

      public void lock()
      Specified by:
      lock in interface Lock
    • lockInterruptibly

      public void lockInterruptibly() throws InterruptedException
      Specified by:
      lockInterruptibly in interface Lock
      Throws:
      InterruptedException
    • tryLock

      public boolean tryLock()
      Specified by:
      tryLock in interface Lock
    • tryLock

      public boolean tryLock(long time, @NotNull TimeUnit unit) throws InterruptedException
      Specified by:
      tryLock in interface Lock
      Throws:
      InterruptedException
    • unlock

      public void unlock()
      Specified by:
      unlock in interface Lock
    • newCondition

      @NotNull public Condition newCondition()
      Specified by:
      newCondition in interface Lock
    • getStampChecked

      public long getStampChecked()
      Retrieves the stamp associated with the current lock. 0 if the wrapped StampedLock is not write-locked. This method is thread-checking.
      Returns:
      lock stam[ or 0 if not locked.
      Throws:
      IllegalCallerException - if the StampedLock is write-locked and the calling thread is not the lock owner
      Since:
      2.3.0
    • unlock

      public void unlock(long stamp)
      Unlock the wrapped StampedLock using the given stamp. This can be called by any thread.
      Parameters:
      stamp - Stamp to unlock with
      Throws:
      IllegalMonitorStateException - if the given stamp does not match the lock's stamp
      Since:
      2.3.0
    • isLocked

      public boolean isLocked()
      Returns true if the lock is currently held.
      Returns:
      true if the lock is currently held.
      Since:
      2.3.0