|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ASemaphore
This is an asynchronous version of Semaphore
. It maintain internal
balance of permits. The method release(int)
increases the amount of
permits and the method acquire(int)
reduces the amount. However the
method acquire reduces amount of permits and resolves its result promise only
when amount of permits will be at least zero after substracting the permits.
The method drainPermits()
resets the amount of permits to zero when
all previously enqueued acquire(int)
completed.
Ivocations of the methods acquire(int)
and drainPermits()
are ordered. the later invocation will not be executed until the first one is
complete. In contrast to it, the release(int)
methods are not
queued. They are executed as soon as they are received.
Method Summary | |
---|---|
Promise<Void> |
acquire()
|
Promise<Void> |
acquire(int number)
Aquiree a number of permits |
Promise<Integer> |
availablePermits()
This is amount of permits that are released but have not yet been acquired with a acquire(int) call. |
Promise<Integer> |
drainPermits()
Drain all available permits. |
Promise<Integer> |
permitsBalance()
|
void |
release()
Release a permit |
void |
release(int number)
Release a number of permits |
Methods inherited from interface net.sf.asyncobjects.AsyncObject |
---|
dereference, isImmediate |
Method Detail |
---|
Promise<Void> acquire()
Promise<Void> acquire(int number)
number
- amount of permits to aquired
void release()
void release(int number)
number
- a number of permitsPromise<Integer> availablePermits()
acquire(int)
call. If there are pending
acquire(int)
call, this could happen due to several reasons:
acquire(int)
call could be not yet awaken.acquire(int)
is greater than amount of
available permits.
Promise<Integer> permitsBalance()
acquire(int)
calls is substracted from available
permits.Promise<Integer> drainPermits()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |