Win32 (Windows NT and Windows 95) Gate Class Implementation
class Gate {
private:
HANDLE gate;
public:
Gate(void) {
gate = CreateEvent((void*), TRUE, FALSE, (void*)0);
}
~Gate(void) {
CloseHandle(gate);
}
void Open(void) {
SetEvent(gate);
};
void Close(void) {
ResetEvent(gate);
}
// temporarily open the gate, allowing any waiting threads to
// proceed
void Release(void) {
PulseEvent(gate);
}
void Wait(void) {
WaitForSingleObject(gate, INFINITE);
}
};