Fix a problem that caused the new interface code to not actually be
[mesa.git] / src / glut / beos / glutBlocker.h
1 /***********************************************************
2 * Copyright (C) 1997, Be Inc. All rights reserved.
3 *
4 * FILE: glutBlocker.h
5 *
6 * DESCRIPTION: helper class for GLUT event loop.
7 * if a window receives an event, wake up the event loop.
8 ***********************************************************/
9
10 /***********************************************************
11 * Headers
12 ***********************************************************/
13 #include <kernel/OS.h>
14
15 /***********************************************************
16 * CLASS: GlutBlocker
17 *
18 * DESCRIPTION: Fairly naive, but safe implementation.
19 * global semaphore controls access to state
20 * event semaphore blocks WaitEvent() call if necessary
21 * (this is basically a condition variable class)
22 ***********************************************************/
23 class GlutBlocker {
24 public:
25 GlutBlocker();
26 ~GlutBlocker();
27 void WaitEvent(); // wait for new event
28 void WaitEvent(bigtime_t usecs); // wait with timeout
29 void NewEvent(); // new event from a window (may need to wakeup main thread)
30 void QuickNewEvent() { events = true; } // new event from main thread
31 void ClearEvents() { events = false; } // clear counter at beginning of event loop
32 bool PendingEvent() { return events; } // XPending() equivalent
33 private:
34 sem_id gSem;
35 sem_id eSem;
36 bool events; // are there any new events?
37 bool sleeping; // is someone sleeping on eSem?
38 };
39
40 /***********************************************************
41 * Global variable
42 ***********************************************************/
43 extern GlutBlocker gBlock;