Package org.redisson.api
Interface RSemaphoreRx
-
- All Superinterfaces:
RExpirableRx
,RObjectRx
public interface RSemaphoreRx extends RExpirableRx
RxJava2 interface of Redis basedSemaphore
.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 io.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>
availablePermits()
Returns amount of available permits.io.reactivex.rxjava3.core.Single<Integer>
drainPermits()
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>
tryAcquire()
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)
Tries to acquire defined amount of currently availablepermits
.io.reactivex.rxjava3.core.Single<Boolean>
tryAcquire(long waitTime, TimeUnit unit)
Tries to acquire currently available permit.io.reactivex.rxjava3.core.Single<Boolean>
trySetPermits(int permits)
Tries to set number of permits.-
Methods inherited from interface org.redisson.api.RExpirableRx
clearExpire, expire, expireAt, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RObjectRx
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
-
-
-
Method Detail
-
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
io.reactivex.rxjava3.core.Single<Boolean> tryAcquire(int permits)
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
io.reactivex.rxjava3.core.Single<Boolean> trySetPermits(int permits)
Tries to set number of permits.- Parameters:
permits
- - number of permits- Returns:
true
if permits has been set successfully, otherwisefalse
.
-
tryAcquire
io.reactivex.rxjava3.core.Single<Boolean> tryAcquire(long waitTime, TimeUnit unit)
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
-
tryAcquire
io.reactivex.rxjava3.core.Single<Boolean> tryAcquire(int permits, long waitTime, TimeUnit unit)
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
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
-
-