public interface RPermitExpirableSemaphore extends RExpirable, RPermitExpirableSemaphoreAsync
Each permit identified by own id and could be released only using its id. Permit id is a 128-bits unique random identifier generated each time during acquiring.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
| Modifier and Type | Method and Description |
|---|---|
String |
acquire()
Acquires a permit and returns its id.
|
String |
acquire(long leaseTime,
TimeUnit unit)
Acquires a permit with defined
leaseTime and return its id. |
void |
addPermits(int permits)
Increases or decreases the number of available permits by defined value.
|
int |
availablePermits()
Returns amount of available permits.
|
void |
release(String permitId)
Releases a permit by its id.
|
String |
tryAcquire()
Tries to acquire currently available permit and return its id.
|
String |
tryAcquire(long waitTime,
long leaseTime,
TimeUnit unit)
Tries to acquire currently available permit
with defined
leaseTime and return its id. |
String |
tryAcquire(long waitTime,
TimeUnit unit)
Tries to acquire currently available permit and return its id.
|
boolean |
tryRelease(String permitId)
Tries to release permit by its id.
|
boolean |
trySetPermits(int permits)
Tries to set number of permits.
|
boolean |
updateLeaseTime(String permitId,
long leaseTime,
TimeUnit unit)
Overrides and updates lease time for defined permit id.
|
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLiveaddListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlinkacquireAsync, acquireAsync, addPermitsAsync, availablePermitsAsync, releaseAsync, tryAcquireAsync, tryAcquireAsync, tryAcquireAsync, tryReleaseAsync, trySetPermitsAsync, updateLeaseTimeAsyncclearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsyncaddListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsyncString acquire() throws InterruptedException
InterruptedException - if the current thread is interruptedString acquire(long leaseTime, TimeUnit unit) throws InterruptedException
leaseTime and return its id.
Waits if necessary until a permit became available.leaseTime - permit lease timeunit - time unitInterruptedException - if the current thread is interruptedString tryAcquire()
null
otherwiseString tryAcquire(long waitTime, TimeUnit unit) throws InterruptedException
waitTime if necessary until a permit became available.waitTime - the maximum time to waitunit - the time unitnull
if the waiting time elapsed before a permit was acquiredInterruptedException - if the current thread is interruptedString tryAcquire(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException
leaseTime and return its id.
Waits up to defined waitTime if necessary until a permit became available.waitTime - the maximum time to waitleaseTime - permit lease time, use -1 to make it permanentunit - the time unitnull
if the waiting time elapsed before a permit was acquiredInterruptedException - if the current thread is interruptedboolean tryRelease(String permitId)
permitId - permit idtrue if a permit has been released and false
otherwisevoid release(String permitId)
permitId - - permit idint availablePermits()
boolean trySetPermits(int permits)
permits - - number of permitstrue if permits has been set successfully, otherwise false.void addPermits(int permits)
permits - amount of permits to add/removeboolean updateLeaseTime(String permitId, long leaseTime, TimeUnit unit)
permitId - permit idleaseTime - permit lease time, use -1 to make it permanentunit - the time unittrue if permits has been updated successfully, otherwise false.Copyright © 2014–2021 Redisson. All rights reserved.