K - the event key.R - the event result.E - the exception which could be thrown by the action.public class EventManger<K,R,E extends java.lang.Exception>
extends java.lang.Object
Events are distinguished by an unique event key. They can produce an event result, which can simply be null.
The action is able to throw an exception.
| Modifier and Type | Class and Description |
|---|---|
static interface |
EventManger.Callback<E extends java.lang.Exception> |
| Constructor and Description |
|---|
EventManger() |
| Modifier and Type | Method and Description |
|---|---|
R |
performActionAndWaitForEvent(K eventKey,
long timeout,
EventManger.Callback<E> action)
Perform an action and wait for an event.
|
boolean |
signalEvent(K eventKey,
R eventResult)
Signal an event and the event result.
|
public R performActionAndWaitForEvent(K eventKey, long timeout, EventManger.Callback<E> action) throws java.lang.InterruptedException, E extends java.lang.Exception
The event is signaled with signalEvent(Object, Object).
eventKey - the event key, must not be null.timeout - the timeout to wait for the event in milliseconds.action - the action to perform prior waiting for the event, must not be null.java.lang.InterruptedException - if interrupted while waiting for the event.EE extends java.lang.Exceptionpublic boolean signalEvent(K eventKey, R eventResult)
This method will return false if the event was not created with
performActionAndWaitForEvent(Object, long, Callback).
eventKey - the event key, must not be null.eventResult - the event result, may be null.