Class AbstractAutoClosingLock

java.lang.Object
com.pnfsoftware.jeb.util.concurrent.AbstractAutoClosingLock
All Implemented Interfaces:
AutoCloseable2, ACLock, AutoCloseable

public class AbstractAutoClosingLock extends Object implements ACLock
Base implementation for auto-closable locks.

Guideline for implementers:

  • call super()
  • acquire the lock
  • set the protected field locked to true.
  • Field Details

    • locked

      protected AtomicBoolean locked
      Indicates whether this wrapper currently owns the underlying lock.
  • Constructor Details

    • AbstractAutoClosingLock

      public AbstractAutoClosingLock(SerReentrantLock lock)
      Create a wrapper for the provided lock.
      Parameters:
      lock - lock to release when close() is called
  • Method Details

    • close

      public final void close()
      Release the wrapped lock if it is currently held by this auto-closing wrapper.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface AutoCloseable2