aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classes/share/javax/media/j3d/BehaviorScheduler.java6
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java41
2 files changed, 38 insertions, 9 deletions
diff --git a/src/classes/share/javax/media/j3d/BehaviorScheduler.java b/src/classes/share/javax/media/j3d/BehaviorScheduler.java
index a152408..6a59952 100644
--- a/src/classes/share/javax/media/j3d/BehaviorScheduler.java
+++ b/src/classes/share/javax/media/j3d/BehaviorScheduler.java
@@ -172,9 +172,9 @@ class BehaviorScheduler extends J3dThread {
behav.processStimulus(wakeupCond.trigEnum);
}
catch (RuntimeException e) {
- if (wakeupCond != null) {
- wakeupCond.cleanTree(behaviorStructure);
- }
+ // Force behavior condition to be unset
+ // Issue 21: don't call cleanTree here
+ behavret.conditionSet = false;
System.err.println("Exception occurred during Behavior execution:");
e.printStackTrace();
}
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index a14014b..71122df 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -1537,7 +1537,7 @@ class MasterControl {
threads = (J3dThreadData []) renderWorkThreads.toArray(false);
size = renderWorkThreads.arraySize();
- View v = null;
+ View v;
J3dThreadData lastRunThread = null;
waitTimestamp++;
sleepTime = Long.MAX_VALUE;
@@ -1545,17 +1545,28 @@ class MasterControl {
boolean threadToRun = false;
boolean needToSetWork = false;
+ // Fix for Issue 12: loop through the list of threads, calling
+ // computeCycleTime() exactly once per view. This ensures that
+ // all threads for a given view see consistent values for
+ // isMinCycleTimeAchieve and sleepTime.
+ v = null;
for (i=0; i<size; i++) {
thread = threads[i];
- if (thread.canvas == null) { // Only for swap thread
- ((Object []) thread.threadArgs)[3] = null;
- }
if (thread.view != v) {
thread.view.computeCycleTime();
if (thread.view.sleepTime < sleepTime) {
sleepTime = thread.view.sleepTime;
}
}
+ v = thread.view;
+ }
+
+ v = null;
+ for (i=0; i<size; i++) {
+ thread = threads[i];
+ if (thread.canvas == null) { // Only for swap thread
+ ((Object []) thread.threadArgs)[3] = null;
+ }
if ((thread.lastUpdateTime > thread.lastRunTime) &&
!thread.thread.userStop) {
@@ -1639,9 +1650,27 @@ class MasterControl {
if (needToSetWork && !threadToRun) {
- sleepTime -= (currentTime - lastTime);
+ // Modified the following in the course of fixing Issue 12:
+ //
+ // 1. don't modify sleepTime by subtracting a value that
+ // doesn't even represent time!
+ //
+ // 2. use sleep(sleepTime) rather than wait(sleepTime)
+ //
+ // Note that this will need to be redone anyway for Issue 11
+
+ // BUG: sleepTime -= (currentTime - lastTime);
+
if (sleepTime > 0) {
- runMonitor(SLEEP, null, null, null, null);
+ // OLD: runMonitor(SLEEP, null, null, null, null);
+
+ // System.err.println("MasterControl: sleep(" + sleepTime + ")");
+ try {
+ Thread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ System.err.println(e);
+ }
+ // System.err.println("MasterControl: done sleeping");
}
// Need to invoke MC to do work
// next time after sleep