Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
BlockingEvents


NAME

BlockingEvents - blocking distribution of events

SYNOPSIS

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);

DESCRIPTION

BlockingEvents allows to block the distributor of an event until all recipients have seen it. BlockingEvents is to be seen in comparison to EventConditions which does not block the task which raises an 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.

DIAGNOSTICS

BlockingEvents does not generate itself any diagnostics. TestAndGet returns always FALSE if the given condition has not been returned by Register previously.

SEE ALSO

Conditions
definition of waiting conditions
EventConditions
non-blocking alternative to BlockingEvents
Events
general event handling
Tasks
task management

Edited by: borchert, last change: 1995/10/26, revision: 1.2, converted to HTML: 1997/04/28

Oberon || Library || Module Index || Search Engine || Definition || Module