event_flag

This class encapsulates the Win32 'event' kernel object.

Creation

enum type { auto_reset= 0, manual_reset=1 };
event_flag::event_flag (type tp, bool initial_state=false, const char* name= 0);
The constructor requires you to specify whether this is to be a manual reset or auto reset event. Unlike the Win32 CreateEvent function where I can never remember which way uses TRUE and which uses FALSE, this constructor names them clearly using an enumeration type.

Optionally, you can specify the initial state of the event flag, and a name, which has the same meaning as the last parameter of CreateEvent.

Setting and Resetting

There are member functions for

Waiting

There is a wait member which takes an optional timeout value. This does full error checking (see win_handle's wait function), but is obviously limited to a simple useage.

For more elaborate use, obtain the underlying kernel handle by calling the h member.