Package org.redisson.api
Interface RSemaphoreReactive
- All Superinterfaces:
RExpirableReactive
,RObjectReactive
Reactive interface of Redis based
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono
<Void> acquire()
Acquires a permit.reactor.core.publisher.Mono
<Void> acquire
(int permits) Acquires defined amount ofpermits
.reactor.core.publisher.Mono
<Void> addPermits
(int permits) Increases or decreases the number of available permits by defined value.reactor.core.publisher.Mono
<Integer> Returns amount of available permits.reactor.core.publisher.Mono
<Integer> Acquires and returns all permits that are immediately available.reactor.core.publisher.Mono
<Void> release()
Releases a permit.reactor.core.publisher.Mono
<Void> release
(int permits) Releases defined amount ofpermits
.reactor.core.publisher.Mono
<Boolean> Acquires a permit.reactor.core.publisher.Mono
<Boolean> tryAcquire
(int permits) Tries to acquire defined amount of currently availablepermits
.reactor.core.publisher.Mono
<Boolean> tryAcquire
(int permits, long waitTime, TimeUnit unit) Deprecated.reactor.core.publisher.Mono
<Boolean> tryAcquire
(int permits, Duration waitTime) Tries to acquire defined amount of currently availablepermits
.reactor.core.publisher.Mono
<Boolean> tryAcquire
(long waitTime, TimeUnit unit) Deprecated.reactor.core.publisher.Mono
<Boolean> tryAcquire
(Duration waitTime) Tries to acquire currently available permit.reactor.core.publisher.Mono
<Boolean> trySetPermits
(int permits) Tries to set number of permits.reactor.core.publisher.Mono
<Boolean> trySetPermits
(int permits, Duration timeToLive) Tries to set number of permits with defined time to live.Methods inherited from interface org.redisson.api.RExpirableReactive
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RObjectReactive
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Method Details
-
tryAcquire
reactor.core.publisher.Mono<Boolean> tryAcquire()Acquires a permit. Waits if necessary until a permit became available.- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquire
Tries to acquire defined amount of currently availablepermits
.- Parameters:
permits
- the number of permits to acquire- Returns:
true
if permits were acquired andfalse
otherwise
-
acquire
reactor.core.publisher.Mono<Void> acquire()Acquires a permit. Waits if necessary until a permit became available.- Returns:
- void
-
acquire
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
-
release
reactor.core.publisher.Mono<Void> release()Releases a permit.- Returns:
- void
-
release
Releases defined amount ofpermits
.- Parameters:
permits
- amount- Returns:
- void
-
trySetPermits
Tries to set number of permits.- Parameters:
permits
- number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
trySetPermits
Tries to set number of permits with defined time to live.- Parameters:
permits
- number of permitstimeToLive
- time to live- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
tryAcquire
Deprecated.UsetryAcquire(Duration)
instead- Parameters:
waitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquire
Tries to acquire currently available permit. Waits up to definedwaitTime
if necessary until a permit became available.- Parameters:
waitTime
- the maximum time to wait- Returns:
true
if a permit was acquired andfalse
otherwise
-
tryAcquire
@Deprecated reactor.core.publisher.Mono<Boolean> tryAcquire(int permits, long waitTime, TimeUnit unit) Deprecated.UsetryAcquire(int, Duration)
instead- Parameters:
permits
- amount of permitswaitTime
- the maximum time to waitunit
- the time unit- Returns:
true
if permits were acquired andfalse
otherwise
-
tryAcquire
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
-
addPermits
Increases or decreases the number of available permits by defined value.- Parameters:
permits
- amount of permits to add/remove
-
availablePermits
reactor.core.publisher.Mono<Integer> availablePermits()Returns amount of available permits.- Returns:
- number of permits
-
drainPermits
reactor.core.publisher.Mono<Integer> drainPermits()Acquires and returns all permits that are immediately available.- Returns:
- number of permits
-