Package com.pnfsoftware.jeb.core.units
Interface IUnitLock
- All Known Implementing Classes:
PassthroughUnitLock
Definition of a unit model lock. Unit locks are optionally provided by
units.-
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.longGet the default wait time lock acquisition will block before throwing aUnitLockedException.booleanisLocked()Determine if the lock is held by _any_ thread.booleanDetermine if the lock is held by _this_ thread.voidVerify that the lock is help by this thread, and raise an exception if not.
-
Method Details
-
getDefaultBlockTimeoutMs
long getDefaultBlockTimeoutMs()Get the default wait time lock acquisition will block before throwing aUnitLockedException.- 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
boolean isLocked()Determine if the lock is held by _any_ thread. Purely indicative, do not use for synchronization.- Returns:
-
isLockedByCurrentThread
boolean isLockedByCurrentThread()Determine if the lock is held by _this_ thread. Purely indicative, do not use for synchronization.- Returns:
-
verifyLocked
void verifyLocked()Verify that the lock is help by this thread, and raise an exception if not.- Throws:
JebRuntimeException- if the lock is not owned by the calling thread
-
a
ACLock a()Attempt to acquire an auto-closable wrapper on this unit lock. If the lock cannot be acquired within the time frame defined bygetDefaultBlockTimeoutMs(), it will throw aUnitLockedException(seegetDefaultBlockTimeoutMs()).Best-practice: This method must be called in a try-with-resources.
- Returns:
-
a
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(seegetDefaultBlockTimeoutMs()).Best-practice: This method must be called in a try-with-resources.
- Parameters:
blockTimeoutMs-- Returns:
-