com.ibm.wbi.util
Class EventSemaphore

java.lang.Object
  |
  +--com.ibm.wbi.util.EventSemaphore

public final class EventSemaphore
extends java.lang.Object

EventSemaphore implments a standard wait/post model semaphore.


Field Summary
static long SEM_INDEFINITE_WAIT
          Waits should wait forever.
 
Constructor Summary
EventSemaphore()
          Create a semaphore.
EventSemaphore(boolean posted)
          Create a semaphore with an optional posted state.
 
Method Summary
 int clear()
          Clear the current semaphore.
 int post()
          Posts the current semaphore.
 int queryPosts()
          Query the number of posts.
 int waitFor()
          Indefinite wait for a post to satisfy our wait.
 int waitFor(long waitMilliSeconds)
          Bounded wait for a post to satisfy our wait.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEM_INDEFINITE_WAIT

public static final long SEM_INDEFINITE_WAIT
Waits should wait forever.
Constructor Detail

EventSemaphore

public EventSemaphore()
Create a semaphore.

EventSemaphore

public EventSemaphore(boolean posted)
Create a semaphore with an optional posted state.
Parameters:
posted - If true, the initial post count is 1, 0 otherwise.
Method Detail

post

public int post()
Posts the current semaphore.
Returns:
The current number of posts.

clear

public int clear()
Clear the current semaphore.
Returns:
The current number of posts before the clear.

queryPosts

public int queryPosts()
Query the number of posts.
Returns:
The current number of posts.

waitFor

public int waitFor()
Indefinite wait for a post to satisfy our wait.
Returns:
The current number of posts.

waitFor

public int waitFor(long waitMilliSeconds)
Bounded wait for a post to satisfy our wait. Note that if the time expires the number of posts returned will be 0.
Parameters:
waitMilliSeconds - The number of uSeconds to wait before returning.
Returns:
The current number of posts.