Events <event.h>

Top  Previous  Next

This group of functions allows a Diamond program to create and manipulate events, which can be used to synchronize the activity of several concurrently executing threads.

 

The header file <event.h> declares a type EVENT that is used by these functions.

 

Events are similar to semaphores, the main difference being that while signalling a semaphore can restart only one waiting thread, setting or pulsing an event restarts all of the waiting threads.

 

An event can be in one of three states:

 


EVENT_NO

the event has not been set and no threads are waiting.


EVENT_YES

the event has been set and so no threads can be waiting.


other

the event has not been set and threads are waiting

 

Programs should not rely on any relationship between the order in which threads start to wait on an event and the order in which they are resumed.

 


event_pulse

indivisibly set and then immediately reset an event


event_init

initialize an event.


event_reset

safely reset an event. Assigning EVENT_NO is safe when the state of the event is EVENT_YES.


event_set

set an event.


event_wait

wait for an event to be set.