Class ReentrantJavaReadWriteLock
java.lang.Object
software.xdev.spring.data.eclipse.store.repository.support.concurrency.ReentrantJavaReadWriteLock
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> Tread(ValueOperation<T> operation) Executes an operation protected by a read lock.final voidread(VoidOperation operation) Executes an operation protected by a read lock.final <T> Twrite(ValueOperation<T> operation) Executes an operation protected by a write lock.final voidwrite(VoidOperation operation) Executes an operation protected by a write lock.
-
Constructor Details
-
ReentrantJavaReadWriteLock
public ReentrantJavaReadWriteLock()
-
-
Method Details
-
read
Executes an operation protected by a read lock.- Specified by:
readin interfaceReadWriteLock- Type Parameters:
T- the operation's return type- Parameters:
operation- the operation to execute- Returns:
- the operation's result
-
read
Executes an operation protected by a read lock.- Specified by:
readin interfaceReadWriteLock- Parameters:
operation- the operation to execute
-
write
Executes an operation protected by a write lock.- Specified by:
writein interfaceReadWriteLock- Type Parameters:
T- the operation's return type- Parameters:
operation- the operation to execute- Returns:
- the operation's result
-
write
Executes an operation protected by a write lock.- Specified by:
writein interfaceReadWriteLock- Parameters:
operation- the operation to execute
-