java.lang.Object
software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReentrantJavaReadWriteLock
All Implemented Interfaces:
ReadWriteLock

public class ReentrantJavaReadWriteLock extends Object implements ReadWriteLock
Facility to execute operations with read and write locks.

Non-reentrant read operations are not allowed until all write operations have been finished. Additionally, a write operation can acquire the read lock, but not vice-versa.

  • Constructor Details

    • ReentrantJavaReadWriteLock

      public ReentrantJavaReadWriteLock()
  • Method Details

    • read

      public final <T> T read(ValueOperation<T> operation)
      Executes an operation protected by a read lock.
      Specified by:
      read in interface ReadWriteLock
      Type Parameters:
      T - the operation's return type
      Parameters:
      operation - the operation to execute
      Returns:
      the operation's result
    • read

      public final void read(VoidOperation operation)
      Executes an operation protected by a read lock.
      Specified by:
      read in interface ReadWriteLock
      Parameters:
      operation - the operation to execute
    • write

      public final <T> T write(ValueOperation<T> operation)
      Executes an operation protected by a write lock.
      Specified by:
      write in interface ReadWriteLock
      Type Parameters:
      T - the operation's return type
      Parameters:
      operation - the operation to execute
      Returns:
      the operation's result
    • write

      public final void write(VoidOperation operation)
      Executes an operation protected by a write lock.
      Specified by:
      write in interface ReadWriteLock
      Parameters:
      operation - the operation to execute