public interface RSemaphore extends RExpirable, RSemaphoreAsync
Semaphore
.
Works in non-fair mode. Therefore order of acquiring is unpredictable.
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Acquires a permit.
|
void |
acquire(int permits)
Acquires defined amount of
permits . |
void |
addPermits(int permits)
Increases or decreases the number of available permits by defined value.
|
int |
availablePermits()
Returns amount of available permits.
|
int |
drainPermits()
Acquires and returns all permits that are immediately available.
|
void |
reducePermits(int permits)
Deprecated.
|
void |
release()
Releases a permit.
|
void |
release(int permits)
Releases defined amount of
permits . |
boolean |
tryAcquire()
Tries to acquire currently available permit.
|
boolean |
tryAcquire(int permits)
Tries to acquire defined amount of currently available
permits . |
boolean |
tryAcquire(int permits,
long waitTime,
TimeUnit unit)
Tries to acquire defined amount of currently available
permits . |
boolean |
tryAcquire(long waitTime,
TimeUnit unit)
Tries to acquire currently available permit.
|
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
acquireAsync, acquireAsync, addPermitsAsync, availablePermitsAsync, drainPermitsAsync, reducePermitsAsync, releaseAsync, releaseAsync, tryAcquireAsync, tryAcquireAsync, tryAcquireAsync, tryAcquireAsync, trySetPermitsAsync
clearExpireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
void acquire() throws InterruptedException
InterruptedException
- if the current thread was interruptedvoid acquire(int permits) throws InterruptedException
permits
.
Waits if necessary until all permits became available.permits
- the number of permits to acquireInterruptedException
- if the current thread is interruptedIllegalArgumentException
- if permits
is negativeboolean tryAcquire()
true
if a permit was acquired and false
otherwiseboolean tryAcquire(int permits)
permits
.permits
- the number of permits to acquiretrue
if permits were acquired and false
otherwiseboolean tryAcquire(long waitTime, TimeUnit unit) throws InterruptedException
waitTime
if necessary until a permit became available.waitTime
- the maximum time to waitunit
- the time unittrue
if a permit was acquired and false
otherwiseInterruptedException
- if the current thread was interruptedboolean tryAcquire(int permits, long waitTime, TimeUnit unit) throws InterruptedException
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
otherwiseInterruptedException
- if the current thread was interruptedvoid release()
void release(int permits)
permits
.
Increases the number of available permits by permits
amount.permits
- amount of permitsint availablePermits()
int drainPermits()
boolean trySetPermits(int permits)
permits
- - number of permitstrue
if permits has been set successfully,
otherwise false
if permits were already set.@Deprecated void reducePermits(int permits)
void addPermits(int permits)
permits
- amount of permits to add/removeCopyright © 2014–2020 Redisson. All rights reserved.