| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.asyncobjects.AsyncUnicastServer<ASemaphore>
net.sf.asyncobjects.util.Semaphore
public class Semaphore
Asynchronous semaphore service. It works both throw proxy and when used directly in the single thread. This class maintains positive and negative permits separtely. Positive permits is what is avaialbe for the current aquire call. Negative permits is what is scheduled.
| Constructor Summary | |
|---|---|
| Semaphore(int permits)Create semaphore with specified number of permits. | |
| 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 ASemaphore.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 class net.sf.asyncobjects.AsyncUnicastServer | 
|---|
| dereference, export, isImmediate, myVat, promise | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Methods inherited from interface net.sf.asyncobjects.AsyncObject | 
|---|
| dereference, isImmediate | 
| Constructor Detail | 
|---|
public Semaphore(int permits)
permits - amount of permits.| Method Detail | 
|---|
public Promise<Void> acquire()
acquire in interface ASemaphoreASemaphore.acquire()public Promise<Void> acquire(int number)
ASemaphore
acquire in interface ASemaphorenumber - amount of permits to aquired
ASemaphore.acquire(int)public Promise<Integer> availablePermits()
ASemaphoreASemaphore.acquire(int) call. If there are pending
 ASemaphore.acquire(int) call, this could happen due to several reasons:
 ASemaphore.acquire(int) call could be not yet awaken.ASemaphore.acquire(int) is greater than amount of
 available permits.
availablePermits in interface ASemaphoreASemaphore.availablePermits()public Promise<Integer> permitsBalance()
permitsBalance in interface ASemaphoreASemaphore.acquire(int) calls is substracted from available
         permits.ASemaphore.permitsBalance()public Promise<Integer> drainPermits()
ASemaphore
drainPermits in interface ASemaphoreASemaphore.drainPermits()public void release()
ASemaphore
release in interface ASemaphoreASemaphore.release()public void release(int number)
ASemaphore
release in interface ASemaphorenumber - a number of permitsASemaphore.release(int)| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||