Package com.pnfsoftware.jeb.core.units
Class PassthroughUnitLock
java.lang.Object
com.pnfsoftware.jeb.core.units.PassthroughUnitLock
- All Implemented Interfaces:
IUnitLock
Singleton, immutable unit lock implementation that locks nothing.
-
Method Summary
Modifier and TypeMethodDescriptiona()
Attempt to acquire an auto-closable wrapper on this unit lock.a
(long blockTimeoutMs) Attempt to acquire an auto-closable wrapper on this unit lock.long
Get the default wait time lock acquisition will block before throwing aUnitLockedException
.static PassthroughUnitLock
boolean
isLocked()
Determine if the lock is held by _any_ thread.boolean
Determine if the lock is held by _this_ thread.void
Verify that the lock is help by this thread, and raise an exception if not.
-
Method Details
-
getInstance
-
getDefaultBlockTimeoutMs
public long getDefaultBlockTimeoutMs()Description copied from interface:IUnitLock
Get the default wait time lock acquisition will block before throwing aUnitLockedException
.- Specified by:
getDefaultBlockTimeoutMs
in interfaceIUnitLock
- Returns:
- the allowed max blocking time; 0 means never fail (ie, fail if the lock is held by another thread); <0 means wait indefinitely
-
isLocked
public boolean isLocked()Description copied from interface:IUnitLock
Determine if the lock is held by _any_ thread. Purely indicative, do not use for synchronization. -
isLockedByCurrentThread
public boolean isLockedByCurrentThread()Description copied from interface:IUnitLock
Determine if the lock is held by _this_ thread. Purely indicative, do not use for synchronization.- Specified by:
isLockedByCurrentThread
in interfaceIUnitLock
- Returns:
-
verifyLocked
public void verifyLocked()Description copied from interface:IUnitLock
Verify that the lock is help by this thread, and raise an exception if not.- Specified by:
verifyLocked
in interfaceIUnitLock
-
a
Description copied from interface:IUnitLock
Attempt to acquire an auto-closable wrapper on this unit lock. If the lock cannot be acquired within the time frame defined byIUnitLock.getDefaultBlockTimeoutMs()
, it will throw aUnitLockedException
(seeIUnitLock.getDefaultBlockTimeoutMs()
).Best-practice: This method must be called in a try-with-resources.
-
a
Description copied from interface:IUnitLock
Attempt to acquire an auto-closable wrapper on this unit lock. If the lock cannot be acquired within the provided time frame, the method will throw aUnitLockedException
(seeIUnitLock.getDefaultBlockTimeoutMs()
).Best-practice: This method must be called in a try-with-resources.
-