Class NamedSimpleReentrantLock.AcquireResult
- java.lang.Object
-
- org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.AcquireResult
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
NamedSimpleReentrantLock.Acquired
- Enclosing class:
- NamedSimpleReentrantLock<T>
public abstract static class NamedSimpleReentrantLock.AcquireResult extends Object implements AutoCloseable
Base result of a locking operation. It indicates whether the operation was successful viawasAcquired()
. Once the lock (acquired or otherwise) is no longer need,close()
needs to be invoked. This is typically done through a try-with-resources block.
-
-
Constructor Summary
Constructors Constructor Description AcquireResult()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract void
close()
Revert the lock operation.abstract boolean
wasAcquired()
Indication whether the lock operation succeeded, in which case this method returns true.
-
-
-
Method Detail
-
wasAcquired
public abstract boolean wasAcquired()
Indication whether the lock operation succeeded, in which case this method returns true. This does not mean that the lock is still being held.- Returns:
- True if the lock was successfully acquired by the operation which produced this object.
-
close
public abstract void close()
Revert the lock operation. IfwasAcquired()
returns true, this method releases the underlying lock in an idempotent way. IfwasAcquired()
returns false, this method does nothing.- Specified by:
close
in interfaceAutoCloseable
-
-