This class manages the event model of Java in a similar, thread-driven model to that of forte. Forte events comprise of events, event loops and event handlers.
Event loops register for events, then wait for events and process those events when received. Event handlers can only be registered within an event loop, and the events received by event handlers are processed by the thread that started the event loop, but external to it, in a callback fashion.
There can ever be only one registration for a particular event within a single event loop (in a when clause). Subsequent re-registration of the same event will result in the latest event registered being used. This will be referred to as the default event handler for an event, as it is not invoked via a callback, but rather as a return from _waitForEvent.
In contrast, event handlers can be infinitely nested within the same event loop for the same event. It is the latest registered handler that is invoked when the event occurs, unless that event handler has been deregistered, in which case the next latest one is used, and so on. Note that events registered before the default event handler (in a pre-register block, for example) can never be invoked, as the default handlers only get deregistered when the event loop ends
To further complicate this picture, event loops may also be nested, that is a new event loop may be started in response to an event from within an event loop. This is particularly true for the case of modal windows.
If a thread processing an inner loop is registered for an event A on object B, and the outer loop for that thread also registers for event A on object B, then only the inner loop will catch the event.
However, if the thread processing an inner loop is registered for event A on object B, and outer loop registers for event A on object C (or indeed any event that is not registered on any inner loop), the object is posted to the outer event queue, which will not receive it until it has terminated the inner loop.
@since 14/02/2004
@author tfaulkes