Interface LockManager
- All Known Implementing Classes:
LockManagerImpl
public interface LockManager
- Author:
- Filip Hrisafov
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Acquire the lock.boolean
acquireLock
(Duration lockForceAcquireAfter) Acquire the lock.void
Release the lock and delete the resources for the lock if needed.void
Release the lock.void
waitForLock
(Duration waitTime) Wait for the givenwaitTime
to acquire the lock<T> T
waitForLockRunAndRelease
(Duration waitTime, Supplier<T> supplier) Wait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.
-
Method Details
-
waitForLock
Wait for the givenwaitTime
to acquire the lock- Parameters:
waitTime
- the duration to wait before throwing an exception
-
acquireLock
boolean acquireLock()Acquire the lock.- Returns:
true
if the lock was acquired,false
otherwise
-
acquireLock
Acquire the lock. ThelockForceAcquireAfter
will be used to acquire an expired lock- Parameters:
lockForceAcquireAfter
- the amount of time after which the lock should be acquired- Returns:
true
if the lock was acquired,false
otherwise
-
releaseLock
void releaseLock()Release the lock. -
releaseAndDeleteLock
void releaseAndDeleteLock()Release the lock and delete the resources for the lock if needed. -
waitForLockRunAndRelease
Wait to acquire a lock, once a lock is acquired execute the supplier and release finally the lock.- Parameters:
waitTime
- the duration to wait before throwing an exceptionsupplier
- the supplier to be executed once the lock is acquired- Returns:
- the result from the
supplier
-