Package net.morimekta.util.concurrent
Class ReentrantReadWriteMutex
- java.lang.Object
-
- net.morimekta.util.concurrent.ReentrantReadWriteMutex
-
- All Implemented Interfaces:
ReadWriteMutex
public class ReentrantReadWriteMutex extends java.lang.Object implements ReadWriteMutex
A re-entrant read-write mutex wrapper.
-
-
Constructor Summary
Constructors Constructor Description ReentrantReadWriteMutex()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidlockForReading(java.lang.Runnable callable)Lock the config for a read operation that must be read atomic.<V> VlockForReading(java.util.function.Supplier<V> callable)Lock the config for a read operation that must be read atomic.voidlockForWriting(java.lang.Runnable callable)Lock the config for a write operation that must be write atomic, and could interfere with read operations.<V> VlockForWriting(java.util.function.Supplier<V> callable)Lock the config for a write operation that must be write atomic, and could interfere with read operations.
-
-
-
Method Detail
-
lockForReading
public void lockForReading(java.lang.Runnable callable)
Description copied from interface:ReadWriteMutexLock the config for a read operation that must be read atomic.- Specified by:
lockForReadingin interfaceReadWriteMutex- Parameters:
callable- The callable operation.
-
lockForReading
public <V> V lockForReading(java.util.function.Supplier<V> callable)
Description copied from interface:ReadWriteMutexLock the config for a read operation that must be read atomic.- Specified by:
lockForReadingin interfaceReadWriteMutex- Type Parameters:
V- The read return value type.- Parameters:
callable- The enclosed callable to be run inside read lock.- Returns:
- The supplied value.
-
lockForWriting
public void lockForWriting(java.lang.Runnable callable)
Description copied from interface:ReadWriteMutexLock the config for a write operation that must be write atomic, and could interfere with read operations.- Specified by:
lockForWritingin interfaceReadWriteMutex- Parameters:
callable- The callable operation.
-
lockForWriting
public <V> V lockForWriting(java.util.function.Supplier<V> callable)
Description copied from interface:ReadWriteMutexLock the config for a write operation that must be write atomic, and could interfere with read operations.- Specified by:
lockForWritingin interfaceReadWriteMutex- Type Parameters:
V- The write return value type.- Parameters:
callable- The callable operation.- Returns:
- The supplied value.
-
-