aboutsummaryrefslogtreecommitdiff
path: root/src/glut/beos/glutBlocker.h
diff options
context:
space:
mode:
authorftrapero <frantracer@gmail.com>2017-06-27 12:08:38 +0200
committerftrapero <frantracer@gmail.com>2017-06-27 12:08:38 +0200
commit663631725ee2d633d9ec5821cd48953ffd188d00 (patch)
tree6d5cd671dd0fd27072661ab83a43f650295a980d /src/glut/beos/glutBlocker.h
downloadnx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.tar.gz
nx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.tar.bz2
nx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.zip
Squashed 'nx-X11/extras/Mesa_6.4.2/' content from commit 475b1f7
git-subtree-dir: nx-X11/extras/Mesa_6.4.2 git-subtree-split: 475b1f7b56fa36ef4f3b22a749f88a98ddc0d502
Diffstat (limited to 'src/glut/beos/glutBlocker.h')
-rw-r--r--src/glut/beos/glutBlocker.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/glut/beos/glutBlocker.h b/src/glut/beos/glutBlocker.h
new file mode 100644
index 000000000..fc9e4cc30
--- /dev/null
+++ b/src/glut/beos/glutBlocker.h
@@ -0,0 +1,47 @@
+/***********************************************************
+ * 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(); // 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;