Package org.redisson.api
Interface RSemaphoreAsync
- All Superinterfaces:
RExpirableAsync
,RObjectAsync
- All Known Subinterfaces:
RSemaphore
- All Known Implementing Classes:
RedissonQueueSemaphore
,RedissonSemaphore
Async interface of Redis based
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionAcquires a permit.acquireAsync
(int permits) Acquires defined amount ofpermits
.addPermitsAsync
(int permits) Increases or decreases the number of available permits by defined value.Returns amount of available permits.Acquires and returns all permits that are immediately available.Releases a permit.releaseAsync
(int permits) Releases defined amount ofpermits
.Acquires a permit.tryAcquireAsync
(int permits) Tries to acquire defined amount of currently availablepermits
.tryAcquireAsync
(int permits, long waitTime, TimeUnit unit) Tries to acquire defined amount of currently availablepermits
.tryAcquireAsync
(long waitTime, TimeUnit unit) Tries to acquire currently available permit.trySetPermitsAsync
(int permits) Tries to set number of permits.Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, 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 Details
-
tryAcquireAsync
Acquires a permit. Waits if necessary until a permit became available.- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquireAsync
Tries to acquire defined amount of currently availablepermits
.- Parameters:
permits
- the number of permits to acquire- Returns:
true
if permits were acquired andfalse
otherwise
-
acquireAsync
Acquires a permit. Waits if necessary until a permit became available.- Returns:
- void
-
acquireAsync
Acquires defined amount ofpermits
. Waits if necessary until all permits became available.- Parameters:
permits
- the number of permits to acquire- Returns:
- void
- Throws:
IllegalArgumentException
- ifpermits
is negative
-
releaseAsync
Releases a permit.- Returns:
- void
-
releaseAsync
Releases defined amount ofpermits
.- Parameters:
permits
- amount- Returns:
- void
-
trySetPermitsAsync
Tries to set number of permits.- Parameters:
permits
- - number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
tryAcquireAsync
Tries to acquire currently available permit. Waits up to definedwaitTime
if necessary until a permit became available.- Parameters:
waitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquireAsync
Tries to acquire defined amount of currently availablepermits
. Waits up to definedwaitTime
if necessary until all permits became available.- Parameters:
permits
- amount of permitswaitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if permits were acquired andfalse
otherwise
-
addPermitsAsync
Increases or decreases the number of available permits by defined value.- Parameters:
permits
- amount of permits to add/remove
-
availablePermitsAsync
Returns amount of available permits.- Returns:
- number of permits
-
drainPermitsAsync
Acquires and returns all permits that are immediately available.- Returns:
- number of permits
-