Class AbstractAutoClosingLock
java.lang.Object
com.pnfsoftware.jeb.util.concurrent.AbstractAutoClosingLock
- All Implemented Interfaces:
AutoCloseable2,ACLock,AutoCloseable
Base implementation for auto-closable locks.
Guideline for implementers:
- call
super() - acquire the lock
- set the protected field
lockedto true.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicBooleanIndicates whether this wrapper currently owns the underlying lock. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a wrapper for the provided lock. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Release the wrapped lock if it is currently held by this auto-closing wrapper.
-
Field Details
-
locked
Indicates whether this wrapper currently owns the underlying lock.
-
-
Constructor Details
-
AbstractAutoClosingLock
Create a wrapper for the provided lock.- Parameters:
lock- lock to release whenclose()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:
closein interfaceAutoCloseable- Specified by:
closein interfaceAutoCloseable2
-