Class LockingVisitors.ReentrantLockVisitor<O>
- java.lang.Object
-
- org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor<O,java.util.concurrent.locks.ReentrantLock>
-
- org.apache.commons.lang3.concurrent.locks.LockingVisitors.ReentrantLockVisitor<O>
-
- Type Parameters:
O
- The type of the object to protect.
- Enclosing class:
- LockingVisitors
public static class LockingVisitors.ReentrantLockVisitor<O> extends LockingVisitors.LockVisitor<O,java.util.concurrent.locks.ReentrantLock>
Wraps aReentrantLock
and object to protect. To access the object, use the methodsLockingVisitors.LockVisitor.acceptReadLocked(FailableConsumer)
,LockingVisitors.LockVisitor.acceptWriteLocked(FailableConsumer)
,LockingVisitors.LockVisitor.applyReadLocked(FailableFunction)
, andLockingVisitors.LockVisitor.applyWriteLocked(FailableFunction)
. The visitor holds the lock while the consumer or function is called.- Since:
- 3.18.0
- See Also:
LockingVisitors.reentrantLockVisitor(Object)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LockingVisitors.ReentrantLockVisitor.Builder<O>
BuildsLockingVisitors.LockVisitor
instances.-
Nested classes/interfaces inherited from class org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor
LockingVisitors.LockVisitor.LVBuilder<O,L,B extends LockingVisitors.LockVisitor.LVBuilder<O,L,B>>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReentrantLockVisitor(O object, java.util.concurrent.locks.ReentrantLock reentrantLock)
Creates a new instance with the given object and lock.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <O> LockingVisitors.ReentrantLockVisitor.Builder<O>
builder()
Creates a new builder.-
Methods inherited from class org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor
acceptReadLocked, acceptWriteLocked, applyReadLocked, applyWriteLocked, getLock, getObject, lockAcceptUnlock, lockApplyUnlock
-
-
-
-
Constructor Detail
-
ReentrantLockVisitor
protected ReentrantLockVisitor(O object, java.util.concurrent.locks.ReentrantLock reentrantLock)
Creates a new instance with the given object and lock.This visitor uses the given ReentrantLock for all of its accept and apply methods.
- Parameters:
object
- The object to protect. The caller is supposed to drop all references to the locked object.reentrantLock
- the lock to use.- See Also:
LockingVisitors
-
-
Method Detail
-
builder
public static <O> LockingVisitors.ReentrantLockVisitor.Builder<O> builder()
Creates a new builder.- Type Parameters:
O
- the wrapped object type.- Returns:
- a new builder.
- Since:
- 3.18.0
-
-