public interface AtomicSemaphore extends SyncPrimitive
Semaphore.DEFAULT_OPERATION_TIMEOUT_MILLIS| Modifier and Type | Method and Description |
|---|---|
Version |
acquire()
Acquires a permit from this semaphore.
|
Version |
acquire(int permits)
Acquires the given number of permits from this semaphore,
blocking until all are available.
|
AsyncAtomicSemaphore |
async()
Returns the underlying asynchronous primitive.
|
int |
availablePermits()
Returns the current number of permits available.
|
int |
drainPermits()
Acquires and returns all permits that are immediately available.
|
int |
increasePermits(int permits)
Increases the number of available permits by the indicated
amount.
|
QueueStatus |
queueStatus()
Query the waiting queue status.
|
int |
reducePermits(int permits)
Shrinks the number of available permits by the indicated reduction.
|
void |
release()
Releases a permit.
|
void |
release(int permits)
Releases the given number of permits.
|
Optional<Version> |
tryAcquire()
Acquires a permit, if one is available and returns immediately.
|
Optional<Version> |
tryAcquire(Duration timeout)
Acquires a permit from this semaphore if one becomes available within the given waiting time.
|
Optional<Version> |
tryAcquire(int permits)
Acquires the given number of permits, if they are available and returns immediately.
|
Optional<Version> |
tryAcquire(int permits,
Duration timeout)
Acquires the given number of permits, if they are available within the given waiting time.
|
close, deleteaddStateChangeListener, name, protocol, removeStateChangeListener, typeVersion acquire()
Version acquire(int permits)
permits - permits to acquireOptional<Version> tryAcquire()
true if a permit was acquired and false otherwiseOptional<Version> tryAcquire(int permits)
permits - permits to acquiretrue if a permit was acquired and false otherwiseOptional<Version> tryAcquire(Duration timeout)
timeout - the maximum time to wait for a permittrue if a permit was acquired and false otherwiseOptional<Version> tryAcquire(int permits, Duration timeout)
permits - permits to acquiretimeout - the maximum time to wait for a permittrue if a permit was acquired and false otherwisevoid release()
void release(int permits)
permits - permits to releaseint availablePermits()
int drainPermits()
int increasePermits(int permits)
release in that it does not
effect the amount of permits this caller has acquired.permits - the number of permits to addint reducePermits(int permits)
acquire in that it does not block
waiting for permits to become available and can be reduced to negative.permits - the number of permits to removeQueueStatus queueStatus()
AsyncAtomicSemaphore async()
SyncPrimitiveasync in interface SyncPrimitiveCopyright © 2013–2018. All rights reserved.