Package org.redisson.api
Interface RPermitExpirableSemaphoreAsync
-
- All Superinterfaces:
RExpirableAsync
,RObjectAsync
- All Known Subinterfaces:
RPermitExpirableSemaphore
- All Known Implementing Classes:
RedissonPermitExpirableSemaphore
public interface RPermitExpirableSemaphoreAsync extends RExpirableAsync
Asynchronous interface for Semaphore object with lease time parameter support for each acquired permit.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.
- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RFuture<String>
acquireAsync()
Acquires a permit and returns its id.RFuture<String>
acquireAsync(long leaseTime, TimeUnit unit)
Acquires a permit with definedleaseTime
and return its id.RFuture<Void>
addPermitsAsync(int permits)
Increases or decreases the number of available permits by defined value.RFuture<Integer>
availablePermitsAsync()
Returns amount of available permits.RFuture<Void>
releaseAsync(String permitId)
Releases a permit by its id.RFuture<String>
tryAcquireAsync()
Tries to acquire currently available permit and return its id.RFuture<String>
tryAcquireAsync(long waitTime, long leaseTime, TimeUnit unit)
Tries to acquire currently available permit with definedleaseTime
and return its id.RFuture<String>
tryAcquireAsync(long waitTime, TimeUnit unit)
Tries to acquire currently available permit and return its id.RFuture<Boolean>
tryReleaseAsync(String permitId)
Tries to release permit by its id.RFuture<Boolean>
trySetPermitsAsync(int permits)
Tries to set number of permits.RFuture<Boolean>
updateLeaseTimeAsync(String permitId, long leaseTime, TimeUnit unit)
Overrides and updates lease time for defined permit id.-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
acquireAsync
RFuture<String> acquireAsync()
Acquires a permit and returns its id. Waits if necessary until a permit became available.- Returns:
- permit id
-
acquireAsync
RFuture<String> acquireAsync(long leaseTime, TimeUnit unit)
Acquires a permit with definedleaseTime
and return its id. Waits if necessary until a permit became available.- Parameters:
leaseTime
- permit lease timeunit
- time unit- Returns:
- permit id
-
tryAcquireAsync
RFuture<String> tryAcquireAsync()
Tries to acquire currently available permit and return its id.- Returns:
- permit id if a permit was acquired and
null
otherwise
-
tryAcquireAsync
RFuture<String> tryAcquireAsync(long waitTime, TimeUnit unit)
Tries to acquire currently available permit and return its id. Waits up to definedwaitTime
if necessary until a permit became available.- Parameters:
waitTime
- the maximum time to waitunit
- the time unit- Returns:
- permit id if a permit was acquired and
null
if the waiting time elapsed before a permit was acquired
-
tryAcquireAsync
RFuture<String> tryAcquireAsync(long waitTime, long leaseTime, TimeUnit unit)
Tries to acquire currently available permit with definedleaseTime
and return its id. Waits up to definedwaitTime
if necessary until a permit became available.- Parameters:
waitTime
- the maximum time to waitleaseTime
- permit lease time, use -1 to make it permanentunit
- the time unit- Returns:
- permit id if a permit was acquired and
null
if the waiting time elapsed before a permit was acquired
-
tryReleaseAsync
RFuture<Boolean> tryReleaseAsync(String permitId)
Tries to release permit by its id.- Parameters:
permitId
- permit id- Returns:
true
if a permit has been released andfalse
otherwise
-
releaseAsync
RFuture<Void> releaseAsync(String permitId)
Releases a permit by its id. Increases the number of available permits. Throws an exception if permit id doesn't exist or has already been released.- Parameters:
permitId
- - permit id- Returns:
- void
-
availablePermitsAsync
RFuture<Integer> availablePermitsAsync()
Returns amount of available permits.- Returns:
- number of permits
-
trySetPermitsAsync
RFuture<Boolean> trySetPermitsAsync(int permits)
Tries to set number of permits.- Parameters:
permits
- - number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
addPermitsAsync
RFuture<Void> addPermitsAsync(int permits)
Increases or decreases the number of available permits by defined value.- Parameters:
permits
- amount of permits to add/remove- Returns:
- void
-
updateLeaseTimeAsync
RFuture<Boolean> updateLeaseTimeAsync(String permitId, long leaseTime, TimeUnit unit)
Overrides and updates lease time for defined permit id.- Parameters:
permitId
- permit idleaseTime
- permit lease time, use -1 to make it permanentunit
- the time unit- Returns:
true
if permits has been updated successfully, otherwisefalse
.
-
-