diff options
author | Brian Paul <[email protected]> | 1999-09-16 22:45:24 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 1999-09-16 22:45:24 +0000 |
commit | 4811b7c7e02c0612975a8526f8ebba49ece0e72b (patch) | |
tree | d039cf9b6dd2a9d4fb47b856f1f89adec4ff81f8 /src/glut/beos/glutBlocker.h | |
parent | b9e8741c8f0e5d683df4be09a232aa722589645e (diff) |
initial check-in
Diffstat (limited to 'src/glut/beos/glutBlocker.h')
-rw-r--r-- | src/glut/beos/glutBlocker.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/glut/beos/glutBlocker.h b/src/glut/beos/glutBlocker.h new file mode 100644 index 00000000000..e6d1f4e049f --- /dev/null +++ b/src/glut/beos/glutBlocker.h @@ -0,0 +1,43 @@ +/*********************************************************** + * Copyright (C) 1997, Be Inc. All rights reserved. + * + * 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(); // wait for new event + void WaitEvent(bigtime_t usecs); // wait with timeout + void NewEvent(); // new event from a window (may need to wakeup main thread) + void QuickNewEvent() { events = true; } // new event from main thread + void ClearEvents() { events = false; } // clear counter at beginning of event loop + bool PendingEvent() { return events; } // XPending() equivalent +private: + sem_id gSem; + sem_id eSem; + bool events; // are there any new events? + bool sleeping; // is someone sleeping on eSem? +}; + +/*********************************************************** + * Global variable + ***********************************************************/ +extern GlutBlocker gBlock;
\ No newline at end of file |