@IntegrationFeature(clazz=LockFeature.class, name="lock") public class LockFeatureImpl extends org.adroitlogic.x.api.AbstractIntegrationFeature implements LockFeature
Constructor and Description |
---|
LockFeatureImpl() |
Modifier and Type | Method and Description |
---|---|
Optional<Integer> |
getNextSequenceNumber(String key)
Generate the next sequence number for the given keyPath
|
void |
releaseLock(String lockKey)
Release the acquired
Semaphore based lock for the given lockPath |
void |
releaseReentrantLock(String lockKey)
Release the acquired
ReentrantLock lock for the given lockPath |
boolean |
tryLock(String lockKey)
Attempts to get a
Semaphore based lock for the given lockPath. |
boolean |
tryReentrantLock(String lockKey)
Attempts to get a
ReentrantLock lock for the given lockPath which won't be useful only for acquire and
release using the same thread. |
public Optional<Integer> getNextSequenceNumber(String key)
LockFeature
getNextSequenceNumber
in interface LockFeature
key
- the key to associate the sequence numberpublic boolean tryLock(String lockKey)
LockFeature
Semaphore
based lock for the given lockPath. In this method, it's not required to acquire
and release the lock using the same threadtryLock
in interface LockFeature
lockKey
- the key to get the ReentrantLock
public void releaseLock(String lockKey)
LockFeature
Semaphore
based lock for the given lockPathreleaseLock
in interface LockFeature
lockKey
- the key to find the lock which should be acquired beforepublic boolean tryReentrantLock(String lockKey)
LockFeature
ReentrantLock
lock for the given lockPath which won't be useful only for acquire and
release using the same thread. If it's going to acquire the lock from one thread and release from anther thread,
then this API won't help to facilitate the required synchronization. For those type of scenarios instead of this,
use the tryLock() APItryReentrantLock
in interface LockFeature
lockKey
- the key to get the ReentrantLock
public void releaseReentrantLock(String lockKey)
LockFeature
ReentrantLock
lock for the given lockPathreleaseReentrantLock
in interface LockFeature
lockKey
- the key to find the lock which should be acquired beforeCopyright © 2016–2019 AdroitLogic. All rights reserved.