Class AbstractReadWriteLockOperation

All Implemented Interfaces:
PropertyBindable, PropertyConstrainable, Operation, Task, Runnable, ReadWriteLock

public abstract class AbstractReadWriteLockOperation extends AbstractOperation implements ReadWriteLock
Abstract implementation of some operation that can be executed, with state governed by a read/write lock.

This implementation is thread-safe, providing its own read/write lock. The state is governed by this read/write lock, which can also be used for locking other operation resources.

Author:
Garret Wilson
  • Constructor Details

    • AbstractReadWriteLockOperation

      public AbstractReadWriteLockOperation()
      Default constructor using a reentrant read/write lock.
    • AbstractReadWriteLockOperation

      public AbstractReadWriteLockOperation(ReadWriteLock readWriteLock)
      Read write lock constructor.
      Parameters:
      readWriteLock - The lock for controlling access to the properties.
      Throws:
      NullPointerException - if the given lock is null.
  • Method Details

    • readLock

      public Lock readLock()
      Returns the lock used for reading.
      Specified by:
      readLock in interface ReadWriteLock
      Returns:
      the lock used for reading.
    • writeLock

      public Lock writeLock()
      Returns the lock used for writing.
      Specified by:
      writeLock in interface ReadWriteLock
      Returns:
      the lock used for writing.
    • getState

      public TaskState getState()
      Specified by:
      getState in interface Task
      Overrides:
      getState in class AbstractTask
      Returns:
      The current state of the task.
    • setState

      public void setState(TaskState newState)
      Description copied from class: AbstractTask
      Sets the current state of the task. This is a bound property.
      Overrides:
      setState in class AbstractTask
      Parameters:
      newState - The new state of the task.
      See Also: