Package org.mycore.util.concurrent
Class MCRReadWriteGuard
java.lang.Object
org.mycore.util.concurrent.MCRReadWriteGuard
A MCRReadWriteGuard acts like a
ReadWriteLock
but automatically wraps read and write operations accordingly.- Author:
- Thomas Scheffler (yagee)
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
MCRReadWriteGuard
public MCRReadWriteGuard() -
MCRReadWriteGuard
-
-
Method Details
-
read
Executes the read operation while the read lock is locked. This is a sharable lock. Manyreader
can be executed simultaneously when no write operation is running.- Parameters:
reader
- a read operation that should be guarded.- Returns:
- result of
Supplier.get()
-
write
Executes the write operation while the write lock is locked. This is an exclusive lock. So no other read or write operation can be executed whileoperation
is running.- Parameters:
operation
-
-
lazyLoad
-