Carapace

Event Class

An Event object allows different threads and processes to synchronise. An Event is simply a flag which can be waited upon.

Event Creation

The create function can be used to create an Event:

    (create Event)
This creates an un-named event. If this event object is shared between threads, then multiple threads can wait on it.

Named events are useful for synchronisation across separate processes, since the operating system ensures that events of the same name are, in fact, the same event. In this way, if one process creates an event called Fred then a separate process can also create an event called Fred and they can then synchronise. Named events are created as follows:

    (create Event "Fred")
On creation, the state of the event is 'unset'.

Event Properties

property name property type description
name String the name of the event

Event Methods

method name description
state return the state of the event -- either set or unset
set set the event -- waiting threads will then be notified
isSet determine if the event is set
pulse pulse the event so that any threads waiting on the event are alerted but the event state is unchanged after the pulse
unset unset the event
wait wait for the event to be set


state

Return the state of the event -- either set or unset.

Arguments: none

Return type: String


set

Set the event -- waiting threads will then be notified.

Arguments: none

Return type: the empty List () is returned.


isSet

Unset the event.

Arguments: none

Return type: the Symbol true if the event is set, otherwise the empty List () is returned.


pulse

Plse the event so that any threads waiting on the event are alerted but the event state is unchanged after the pulse

Arguments: none

Return type: the Symbol true if the pulse succeeds, otherwise the empty List () is returned.


unset

Unset the event.

Arguments: none

Return type: the empty List () is returned.


wait

Wait for the event to be set. If the event is set within the specified time, then the Symbol ok is returned, otherwise the empty List () is returned.

To wait on mulitiple events at once, see the global function wait.

Arguments: none

Return type: the Symbol ok or the empty List () is returned.


Contents Index Current topic: objects Related links: built-in objects