aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/GLRunnableTask.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLRunnableTask.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
index 448f68423..244a3fd79 100644
--- a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
+++ b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java
@@ -39,7 +39,8 @@ public class GLRunnableTask implements GLRunnable {
GLRunnable runnable;
Object notifyObject;
boolean catchExceptions;
- boolean isExecuted;
+ volatile boolean isExecuted;
+ volatile boolean isFlushed;
Throwable runnableException;
@@ -48,6 +49,7 @@ public class GLRunnableTask implements GLRunnable {
this.notifyObject = notifyObject ;
this.catchExceptions = catchExceptions;
isExecuted = false;
+ isFlushed = false;
}
public boolean run(GLAutoDrawable drawable) {
@@ -84,8 +86,41 @@ public class GLRunnableTask implements GLRunnable {
}
return res;
}
-
+
+ /**
+ * Simply flush this task and notify a waiting executor.
+ * The executor which might have been blocked until notified
+ * will be unblocked and the task removed from the queue.
+ *
+ * @see #isFlushed()
+ * @see #isInQueue()
+ */
+ public void flush() {
+ if(!isExecuted() && null != notifyObject) {
+ synchronized (notifyObject) {
+ isFlushed=true;
+ notifyObject.notifyAll();
+ }
+ }
+ }
+
+ /**
+ * @return !{@link #isExecuted()} && !{@link #isFlushed()}
+ */
+ public boolean isInQueue() { return !isExecuted && !isFlushed; }
+
+ /**
+ * @return whether this task has been executed.
+ * @see #isInQueue()
+ */
public boolean isExecuted() { return isExecuted; }
+
+ /**
+ * @return whether this task has been flushed.
+ * @see #isInQueue()
+ */
+ public boolean isFlushed() { return isFlushed; }
+
public Throwable getThrowable() { return runnableException; }
}