|
General IRI utilities
|
This is an example on how to use the CEventServer class
This example shows how to handle multiple events using the CEventServer class. The possible actions on events are the same as the one available with the CEvent class, but in this case all the operations are done through the event server, using the unique identifier provided at creation time.
The events are first created with a unique name using the create_event() function and must be destroyed with the delete_event() function. Otherwise the event are kept in memory until the application ends.
The server provides a couple of functions (wait_first() and wait_all()) to wait in any combination of events, build as a stl list object. In these functions a timeout exception is also present.
The output of this example should be something like this:
* Activate event 1 * Activate event 2 * Reset event 1 * Wait for the first event to get active ... 1 * event 1 is not set * event 2 is not set * Activate event 1 * Activate event 2 * All events were active * event 1 is not set * event 2 is not set * [Exception caught] - [CEventServer class] - The maximum time to wait for the event activation has ellapsed - * [Exception caught] - [CEventServer class] - Unknown event - invalid_event *
Before the first exception message, the program will halt for about 1 second. Several errors may be thrown by the CeventServer class:
1.8.6