summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/RunnableExecutor.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/util/RunnableExecutor.java b/src/java/com/jogamp/common/util/RunnableExecutor.java
new file mode 100644
index 0000000..6f18f54
--- /dev/null
+++ b/src/java/com/jogamp/common/util/RunnableExecutor.java
@@ -0,0 +1,23 @@
+package com.jogamp.common.util;
+
+public interface RunnableExecutor {
+ /** {@link RunnableExecutor} implementation simply invoking {@link Runnable#run()},
+ * i.e. on the current thread at the time of calling {@link #invoke(boolean, Runnable)}.
+ */
+ public static final RunnableExecutor currentThreadExecutor = new CurrentThreadExecutor();
+
+ /**
+ * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait.
+ * @param r the {@link Runnable} to be executed.
+ */
+ void invoke(boolean wait, Runnable r);
+
+ static class CurrentThreadExecutor implements RunnableExecutor {
+ private CurrentThreadExecutor() {}
+
+ @Override
+ public void invoke(boolean wait, Runnable r) {
+ r.run();
+ }
+ }
+}