aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-core/src/main/java
diff options
context:
space:
mode:
authorRenanse <[email protected]>2013-03-25 11:23:07 -0500
committerRenanse <[email protected]>2013-03-25 11:23:07 -0500
commit0e0f993b6a7b0902c5f659d14e39e04b596e0239 (patch)
treeb81e777cd82c6fd98d72075c010f552b4b5dd869 /ardor3d-core/src/main/java
parent30b1414f78b0cf1c726730d626de6a820483a02c (diff)
parent12efd9bc12824e4005538eb76002a009b24b4005 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'ardor3d-core/src/main/java')
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java9
-rw-r--r--ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java25
2 files changed, 34 insertions, 0 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
index 11bdd37..6811d5c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTask.java
@@ -141,4 +141,13 @@ public class GameTask<V> implements Future<V> {
}
}
+ public ExecutionException getExecutionException() {
+ _stateLock.lock();
+ try {
+ return _exception;
+ } finally {
+ _stateLock.unlock();
+ }
+ }
+
}
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
index 37e422f..2a0e17c 100644
--- a/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
+++ b/ardor3d-core/src/main/java/com/ardor3d/util/GameTaskQueue.java
@@ -10,8 +10,11 @@
package com.ardor3d.util;
+import java.util.LinkedList;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -28,6 +31,10 @@ import com.ardor3d.renderer.RendererCallable;
*/
public class GameTaskQueue {
+ public interface ExecutionExceptionListener {
+ void executionException(ExecutionException e);
+ }
+
public static final String RENDER = "render";
public static final String UPDATE = "update";
@@ -37,6 +44,16 @@ public class GameTaskQueue {
// Default execution time is 0, which means only 1 task will be executed at a time.
private long _executionTime = 0;
+ private final List<ExecutionExceptionListener> _executionExceptionListeners = new LinkedList<ExecutionExceptionListener>();
+
+ public void addExecutionExceptionListener(final ExecutionExceptionListener l) {
+ _executionExceptionListeners.add(l);
+ }
+
+ public boolean removeExecutionExceptionListener(final ExecutionExceptionListener l) {
+ return _executionExceptionListeners.remove(l);
+ }
+
/**
* The state of this <code>GameTaskQueue</code> if it will execute all enqueued Callables on an execute invokation.
*
@@ -142,6 +159,14 @@ public class GameTaskQueue {
}
}
task.invoke();
+
+ final ExecutionException e = task.getExecutionException();
+ if (e != null) {
+ for (final ExecutionExceptionListener l : _executionExceptionListeners) {
+ l.executionException(e);
+ }
+ }
+
elapsedTime = System.currentTimeMillis() - beginTime;
} while ((_executeMultiple.get()) && (elapsedTime < _executionTime) && ((task = _queue.poll()) != null));
}