Package org.redisson.api
Interface RSemaphoreRx
- All Superinterfaces:
RExpirableRx
,RObjectRx
RxJava2 interface of Redis based
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Completable
acquire()
Acquires a permit.io.reactivex.rxjava3.core.Completable
acquire
(int permits) Acquires defined amount ofpermits
.io.reactivex.rxjava3.core.Completable
addPermits
(int permits) Increases or decreases the number of available permits by defined value.io.reactivex.rxjava3.core.Single
<Integer> Returns amount of available permits.io.reactivex.rxjava3.core.Single
<Integer> Acquires and returns all permits that are immediately available.io.reactivex.rxjava3.core.Completable
release()
Releases a permit.io.reactivex.rxjava3.core.Completable
release
(int permits) Releases defined amount ofpermits
.io.reactivex.rxjava3.core.Single
<Boolean> Acquires a permit.io.reactivex.rxjava3.core.Single
<Boolean> tryAcquire
(int permits) Tries to acquire defined amount of currently availablepermits
.io.reactivex.rxjava3.core.Single
<Boolean> tryAcquire
(int permits, long waitTime, TimeUnit unit) Deprecated.io.reactivex.rxjava3.core.Single
<Boolean> tryAcquire
(int permits, Duration waitTime) Tries to acquire defined amount of currently availablepermits
.io.reactivex.rxjava3.core.Single
<Boolean> tryAcquire
(long waitTime, TimeUnit unit) Deprecated.io.reactivex.rxjava3.core.Single
<Boolean> tryAcquire
(Duration waitTime) Tries to acquire currently available permit.io.reactivex.rxjava3.core.Single
<Boolean> trySetPermits
(int permits) Tries to set number of permits.io.reactivex.rxjava3.core.Single
<Boolean> trySetPermits
(int permits, Duration timeToLive) Tries to set number of permits with defined time to live.Methods inherited from interface org.redisson.api.RExpirableRx
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RObjectRx
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
io.reactivex.rxjava3.core.Single<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
io.reactivex.rxjava3.core.Completable acquire()Acquires a permit. Waits if necessary until a permit became available.- Returns:
- void
-
acquire
io.reactivex.rxjava3.core.Completable acquire(int permits) 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
io.reactivex.rxjava3.core.Completable release()Releases a permit.- Returns:
- void
-
release
io.reactivex.rxjava3.core.Completable release(int permits) 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 io.reactivex.rxjava3.core.Single<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 wait- Returns:
true
if permits were acquired andfalse
otherwise
-
addPermits
io.reactivex.rxjava3.core.Completable addPermits(int permits) Increases or decreases the number of available permits by defined value.- Parameters:
permits
- amount of permits to add/remove
-
availablePermits
io.reactivex.rxjava3.core.Single<Integer> availablePermits()Returns amount of available permits.- Returns:
- number of permits
-
drainPermits
io.reactivex.rxjava3.core.Single<Integer> drainPermits()Acquires and returns all permits that are immediately available.- Returns:
- number of permits
-