|
General IRI utilities
|
This is an example on how to use events
This example shows the basic operation with events and the most important feature, which is the wait() function. This example mainly sets the event several times and waits for it. Most of the times the wait function return immediatelly after being called, and some other times, a timeout error is generated.
In this case the name of the event is just informative, but when the CEventServer class is used, this name is used as a unique identifier of each event.
The output of this example program should be something like this:
* Event identifier: test_event1 * Number of instances of the event: 1 * Number of instances of the event: 1 * [Exception caught] - [CEvent class] - The maximum time to wait for the event activation has ellapsed - test_event1 * Number of instances of the event: 3 * Number of instances of the event: 2 * Number of instances of the event: 1 * Number of instances if the event: 0 *
Before the timeout exception, the program halts for about 1 second, which is the desired timeout. Several error may be thrown by the CEvent class:
1.8.6