2002/08/18 05:30:45
[org.ibex.core.git] / src / org / xwt / MessageQueue.java
index e395d14..5f8b17d 100644 (file)
@@ -32,7 +32,7 @@ public class MessageQueue extends Thread {
     private static Queue events = new Queue(50);
 
     /** the number of objects in the queue that are not subclasses of ThreadMessage */
-    private static volatile int nonThreadEventsInQueue = 0;
+    public static volatile int nonThreadEventsInQueue = 0;
 
     /** the message currently being performed */    
     static Message currentlyPerforming = null;
@@ -115,24 +115,27 @@ public class MessageQueue extends Thread {
         public MessageQueueWatcher() { start(); }
         public void run() {
             while(true) {
-                if (m != null && m == MessageQueue.currentlyPerforming) {
+                if ((m != null && m == MessageQueue.currentlyPerforming) || MessageQueue.working) {
                     Context cx;
                     String what;
-                    if (m instanceof ThreadMessage) {
+                    if (m == null) {
+                        cx = Context.getContextForThread(MessageQueue.singleton);
+                        what = "trap";
+                    } else if (m instanceof ThreadMessage) {
                         ThreadMessage tm = (ThreadMessage)m;
                         cx = Context.getContextForThread(tm);
                         what = "background thread";
                     } else {
                         cx = Context.getContextForThread(MessageQueue.singleton);
-                        what = Main.initializationComplete ? "trap" : "script";
+                        what = "script";
                     }
-                    if (Log.on) Log.log(this, "WARNING: executing same " + what + " for " + (System.currentTimeMillis() - t) / 1000 + "s" +
+                    if (Log.on) Log.log(this, "note: executing same " + what + " for " + (System.currentTimeMillis() - t) / 1000 + "s" +
                                         " at " + cx.interpreterSourceFile + ":" + cx.interpreterLine);
                 } else {
                     m = MessageQueue.currentlyPerforming;
                     t = System.currentTimeMillis();
                 }
-                try { Thread.sleep(Main.initializationComplete ? 1000 : 15000); } catch (Exception e) { }
+                try { Thread.sleep(1000); } catch (Exception e) { }
             }
         }
     }