aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/share/javax/media/j3d/MasterControl.java50
-rw-r--r--src/classes/share/javax/media/j3d/MasterControlThread.java17
2 files changed, 39 insertions, 28 deletions
diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java
index 6f2b105..23e1288 100644
--- a/src/classes/share/javax/media/j3d/MasterControl.java
+++ b/src/classes/share/javax/media/j3d/MasterControl.java
@@ -1194,7 +1194,7 @@ class MasterControl {
*/
void createMasterControlThread() {
running = true;
- workToDo = false;
+ workToDo = true;
state = RUNNING;
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
@@ -2785,7 +2785,7 @@ class MasterControl {
renderMessage.args[1] = arg;
renderMessage.args[2] = mtype;
rdr.rendererStructure.addMessage(renderMessage);
- VirtualUniverse.mc.setWorkForRequestRenderer();
+ setWorkForRequestRenderer();
}
// Fix for Issue 18
@@ -2804,30 +2804,28 @@ class MasterControl {
J3dDebug.doAssert((Screen3D.deviceRendererMap.get(gd) != null),
"Screen3D.deviceRendererMap.get(gd) != null");
- // Create the master control thread if it isn't already created
- boolean needToSetWork = false;
synchronized (mcThreadLock) {
+ // Create the master control thread if it isn't already created
if (mcThread == null) {
//System.err.println("Calling createMasterControlThread()");
createMasterControlThread();
- needToSetWork = true;
}
- }
- if (needToSetWork) {
- setWork();
- }
- // Fix for Issue 72 : call createRenderer rather than getting
- // the renderer from the canvas.screen object
- Renderer rdr = createRenderer(c.graphicsConfiguration);
- J3dMessage createMessage = VirtualUniverse.mc.getMessage();
- createMessage.threads = J3dThread.RENDER_THREAD;
- createMessage.type = J3dMessage.CREATE_OFFSCREENBUFFER;
- createMessage.universe = null;
- createMessage.view = null;
- createMessage.args[0] = c;
- rdr.rendererStructure.addMessage(createMessage);
- VirtualUniverse.mc.setWorkForRequestRenderer();
+ // Fix for Issue 72 : call createRenderer rather than getting
+ // the renderer from the canvas.screen object
+ Renderer rdr = createRenderer(c.graphicsConfiguration);
+ J3dMessage createMessage = VirtualUniverse.mc.getMessage();
+ createMessage.threads = J3dThread.RENDER_THREAD;
+ createMessage.type = J3dMessage.CREATE_OFFSCREENBUFFER;
+ createMessage.universe = null;
+ createMessage.view = null;
+ createMessage.args[0] = c;
+ rdr.rendererStructure.addMessage(createMessage);
+ synchronized (requestObjList) {
+ setWorkForRequestRenderer();
+ pendingRequest = true;
+ }
+ }
}
@@ -2837,14 +2835,14 @@ class MasterControl {
void doWork() {
runMonitor(CHECK_FOR_WORK, null, null, null, null);
- if (pendingRequest) {
- synchronized (timeLock) {
- synchronized (requestObjList) {
+ synchronized (timeLock) {
+ synchronized (requestObjList) {
+ if (pendingRequest) {
handlePendingRequest();
}
}
}
-
+
if (!running) {
return;
}
@@ -3085,7 +3083,7 @@ class MasterControl {
setWork();
}
- if (rendererRun) {
+ if (rendererRun || requestRenderWorkToDo) {
running = true;
}
@@ -3376,9 +3374,9 @@ class MasterControl {
break;
case SET_WORK_FOR_REQUEST_RENDERER:
requestRenderWorkToDo = true;
+ workToDo = true;
if (state == WAITING_FOR_CPU || state == WAITING_FOR_THREADS ||
state == SLEEPING) {
- workToDo = true;
notify();
}
break;
diff --git a/src/classes/share/javax/media/j3d/MasterControlThread.java b/src/classes/share/javax/media/j3d/MasterControlThread.java
index 7a0e869..8157a6c 100644
--- a/src/classes/share/javax/media/j3d/MasterControlThread.java
+++ b/src/classes/share/javax/media/j3d/MasterControlThread.java
@@ -21,8 +21,22 @@ package javax.media.j3d;
*/
class MasterControlThread extends Thread {
+ private static int numInstances = 0;
+ private int instanceNum = -1;
+
+ private static synchronized int newInstanceNum() {
+ return (++numInstances);
+ }
+
+ private int getInstanceNum() {
+ if (instanceNum == -1)
+ instanceNum = newInstanceNum();
+ return instanceNum;
+ }
+
MasterControlThread(ThreadGroup threadGroup) {
- super(threadGroup, "J3D-MasterControl");
+ super(threadGroup, "");
+ setName("J3D-MasterControl-" + getInstanceNum());
VirtualUniverse.mc.createMCThreads();
this.start();
}
@@ -43,6 +57,5 @@ class MasterControlThread extends Thread {
J3dDebug.doDebug(J3dDebug.masterControl, J3dDebug.LEVEL_1,
"MC: MasterControl Thread Terminate");
}
-
}
}