Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE EventType = POINTER TO EventTypeRec; TYPE EventTypeRec = RECORD (Events.EventTypeRec) END;
PROCEDURE Define(VAR type: EventType); PROCEDURE Register(type: EventType; VAR condition: Conditions.Condition); PROCEDURE Unregister(condition: Conditions.Condition); PROCEDURE TestAndGet(condition: Conditions.Condition; VAR event: Events.Event) : BOOLEAN; PROCEDURE Done(condition: Conditions.Condition); PROCEDURE Raise(event: Events.Event);
Register allows a task to register its interest for all events of an event type which has been earlier created by Define. Register returns like EventConditions.Create a condition which allows to wait until an event of the given event type is raised. The registration may be undone by calling Unregister. TestAndGet returns TRUE and the next event if there are any events in the event queue of condition. Done must be called for processed events which has been returned by TestAndGet.
Events.Raise does not necessarily block the caller due to the priority system. Therefore BlockingEvents.Raise should be called instead. But note that BlockingEvents.Raise does not call Events.Raise and thus does not cause other handlers to be called.
Blocking events are not without danger. If registered parties ``forget'' to call TestAndGet and/or Done the event raising task will be deadlocked. For this reason all registered tasks should always include the condition returned by Register into the condition set passed to Tasks.WaitForOneOf. It is not necessary, however, to check for events immediately before calling Unregister because Unregister calls Done for all not yet processed events of the associated event queue.
Oberon || Library || Module Index || Search Engine || Definition || Module