* Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
*
* This program is freely distributable without licensing fees
* and is provided without guarantee or warrantee expressed or
* implied. This program is -not- in the public domain.
*
* FILE: glutBlocker.h
*
* DESCRIPTION: helper class for GLUT event loop.
* if a window receives an event, wake up the event loop.
***********************************************************/
* Headers
***********************************************************/
#include <kernel/OS.h>
* CLASS: GlutBlocker
*
* DESCRIPTION: Fairly naive, but safe implementation.
* global semaphore controls access to state
* event semaphore blocks WaitEvent() call if necessary
* (this is basically a condition variable class)
***********************************************************/
class GlutBlocker {
public:
GlutBlocker();
~GlutBlocker();
void WaitEvent();
void WaitEvent(bigtime_t usecs);
void NewEvent();
void QuickNewEvent() { events = true; }
void ClearEvents() { events = false; }
bool PendingEvent() { return events; }
private:
sem_id gSem;
sem_id eSem;
bool events;
bool sleeping;
};
* Global variable
***********************************************************/
extern GlutBlocker gBlock;