Package org.apache.commons.lang3.concurrent.locks

# Class LockingVisitors.ReadWriteLockVisitor<O>

java.lang.Object
org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor<O,ReadWriteLock>
org.apache.commons.lang3.concurrent.locks.LockingVisitors.ReadWriteLockVisitor<O>

Type Parameters:
  `O` - The type of the object to protect.

Enclosing class:
  `LockingVisitors`

public static class LockingVisitors.ReadWriteLockVisitor<O> extends LockingVisitors.LockVisitor<O,ReadWriteLock>
Wraps a `ReadWriteLock` and object to protect. To access the object, use the methods `LockingVisitors.LockVisitor.acceptReadLocked(FailableConsumer)`, `LockingVisitors.LockVisitor.acceptWriteLocked(FailableConsumer)`, `LockingVisitors.LockVisitor.applyReadLocked(FailableFunction)`, and `LockingVisitors.LockVisitor.applyWriteLocked(FailableFunction)`. The visitor holds the lock while the consumer or function is called.

See Also:
  - `LockingVisitors.create(Object, ReadWriteLock)`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `LockingVisitors.ReadWriteLockVisitor.Builder<O>`
  Builds `LockingVisitors.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`
  `ReadWriteLockVisitor(O object, ReadWriteLock readWriteLock)`
  Creates a new instance with the given object and lock.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <O> LockingVisitors.ReadWriteLockVisitor.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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ReadWriteLockVisitor

    protected ReadWriteLockVisitor(O object, ReadWriteLock readWriteLock)
    Creates a new instance with the given object and lock.
    Parameters:
      `object` - The object to protect. The caller is supposed to drop all references to the locked object.
      `readWriteLock` - the lock to use.
    See Also:
      - `LockingVisitors`

- ## Method Details

  - ### builder

    public static <O> LockingVisitors.ReadWriteLockVisitor.Builder<O> builder()
    Creates a new builder.
    Type Parameters:
      `O` - the wrapped object type.
    Returns:
      a new builder.
    Since:
      3.18.0