public interface RSemaphoreRx extends RExpirableRx
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
Modifier and Type | Method and Description |
---|---|
io.reactivex.Completable |
acquire()
Acquires a permit.
|
io.reactivex.Completable |
acquire(int permits)
Acquires defined amount of
permits . |
io.reactivex.Completable |
addPermits(int permits)
Increases or decreases the number of available permits by defined value.
|
io.reactivex.Single<Integer> |
availablePermits()
Returns amount of available permits.
|
io.reactivex.Single<Integer> |
drainPermits()
Acquires and returns all permits that are immediately available.
|
io.reactivex.Completable |
reducePermits(int permits)
Deprecated.
|
io.reactivex.Completable |
release()
Releases a permit.
|
io.reactivex.Completable |
release(int permits)
Releases defined amount of
permits . |
io.reactivex.Single<Boolean> |
tryAcquire()
Acquires a permit.
|
io.reactivex.Single<Boolean> |
tryAcquire(int permits)
Tries to acquire defined amount of currently available
permits . |
io.reactivex.Single<Boolean> |
tryAcquire(int permits,
long waitTime,
TimeUnit unit)
Tries to acquire defined amount of currently available
permits . |
io.reactivex.Single<Boolean> |
tryAcquire(long waitTime,
TimeUnit unit)
Tries to acquire currently available permit.
|
io.reactivex.Single<Boolean> |
trySetPermits(int permits)
Tries to set number of permits.
|
clearExpire, expire, expireAt, expireAt, remainTimeToLive
addListener, copy, delete, dump, getCodec, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
io.reactivex.Single<Boolean> tryAcquire()
true
if a permit was acquired and false
otherwiseio.reactivex.Single<Boolean> tryAcquire(int permits)
permits
.permits
- the number of permits to acquiretrue
if permits were acquired and false
otherwiseio.reactivex.Completable acquire()
io.reactivex.Completable acquire(int permits)
permits
.
Waits if necessary until all permits became available.permits
- the number of permits to acquireIllegalArgumentException
- if permits
is negativeio.reactivex.Completable release()
io.reactivex.Completable release(int permits)
permits
.permits
- amountio.reactivex.Single<Boolean> trySetPermits(int permits)
permits
- - number of permitstrue
if permits has been set successfully, otherwise false
.io.reactivex.Single<Boolean> tryAcquire(long waitTime, TimeUnit unit)
waitTime
if necessary until a permit became available.waitTime
- the maximum time to waitunit
- the time unittrue
if a permit was acquired and false
otherwiseio.reactivex.Single<Boolean> tryAcquire(int permits, long waitTime, TimeUnit unit)
permits
.
Waits up to defined waitTime
if necessary until all permits became available.permits
- amount of permitswaitTime
- the maximum time to waitunit
- the time unittrue
if permits were acquired and false
otherwise@Deprecated io.reactivex.Completable reducePermits(int permits)
io.reactivex.Completable addPermits(int permits)
permits
- amount of permits to add/removeio.reactivex.Single<Integer> availablePermits()
io.reactivex.Single<Integer> drainPermits()
Copyright © 2014–2020 Redisson. All rights reserved.