Class ReadWriteLockSupport

java.lang.Object
net.emustudio.emulib.ReadWriteLockSupport

@ThreadSafe public final class ReadWriteLockSupport extends Object
Runs actions under a ReentrantReadWriteLock.

Actions can throw checked exceptions; they are rethrown unchanged (see Unchecked).

  • Constructor Details

    • ReadWriteLockSupport

      public ReadWriteLockSupport()
  • Method Details

    • lockWrite

      public void lockWrite(Unchecked.RunnableWhichCanThrow r)
      Runs the action under the write lock.
      Parameters:
      r - the action
    • lockWrite

      public <T> T lockWrite(Unchecked.CallableWithCanThrow<T> c)
      Calls the action under the write lock.
      Type Parameters:
      T - the result type
      Parameters:
      c - the action
      Returns:
      the action result
    • lockRead

      public void lockRead(Unchecked.RunnableWhichCanThrow r)
      Runs the action under the read lock.
      Parameters:
      r - the action
    • lockRead

      public <T> T lockRead(Unchecked.CallableWithCanThrow<T> c)
      Calls the action under the read lock.
      Type Parameters:
      T - the result type
      Parameters:
      c - the action
      Returns:
      the action result