2003/09/07 03:04:31
[org.ibex.core.git] / src / org / xwt / MessageQueue.java
index b6643c6..ffbe064 100644 (file)
@@ -3,7 +3,6 @@ package org.xwt;
 
 import java.util.*;
 import org.xwt.util.*;
-import org.mozilla.javascript.*;
 
 /** 
  *  A singleton class (one instance per JVM) that implements a queue
@@ -41,7 +40,7 @@ public class MessageQueue extends Thread {
     private static MessageQueueWatcher watcher = new MessageQueueWatcher();
 
     // HACK for debugging purposes
-    Function lastfunc = null;
+    Object lastfunc = null;
     Message lastmessage = null;
 
     /**
@@ -88,7 +87,8 @@ public class MessageQueue extends Thread {
                 if (Log.on) Log.log(this, "caught throwable in MessageQueue.run(); this should never happen");
                 if (Log.on) Log.log(this, "    currentlyPerforming == " + currentlyPerforming);
                 if (Log.on) Log.log(this, "    working             == " + working);
-                if (Log.on) Log.log(this, "    lastfunc            == " + lastfunc);
+                // FIXME - this currently calls compiledfunction.toString which gives more info than we need
+                // if (Log.on) Log.log(this, "    lastfunc            == " + lastfunc.getDescription());
                 if (Log.on) Log.log(this, "    lastmessage         == " + lastmessage);
                 if (Log.on) Log.log(this, t);
                 if (Log.on) Log.log(this, "resuming MessageQueue loop");
@@ -115,19 +115,21 @@ public class MessageQueue extends Thread {
         public MessageQueueWatcher() { start(); }
         public void run() {
             while(true) {
-                if (m != null && m == MessageQueue.currentlyPerforming) {
-                    Context cx;
-                    String what;
-                    if (m instanceof ThreadMessage) {
-                        ThreadMessage tm = (ThreadMessage)m;
-                        cx = Context.getContextForThread(tm);
+                if ((m != null && m == MessageQueue.currentlyPerforming) || MessageQueue.working) {
+                    String what, where;
+                    if (m != null && m instanceof ThreadMessage) {
+                        where = org.xwt.js.JS.Thread.fromJavaThread((ThreadMessage)m).getSourceName();
                         what = "background thread";
+                    } else if (m != null) {
+                        where = org.xwt.js.JS.Thread.fromJavaThread(MessageQueue.singleton).getSourceName();
+                        what = "event trap";
                     } else {
-                        cx = Context.getContextForThread(MessageQueue.singleton);
+                        where = org.xwt.js.JS.Thread.fromJavaThread(MessageQueue.singleton).getSourceName();
                         what = "script";
                     }
-                    if (Log.on) Log.log(this, "note: executing same " + what + " for " + (System.currentTimeMillis() - t) / 1000 + "s" +
-                                        " at " + cx.interpreterSourceFile + ":" + cx.interpreterLine);
+                    long howlong = (System.currentTimeMillis() - t) / 1000;
+                    if (howlong >= 5)
+                        if (Log.on) Log.log(this, "note: executing same " + what + " for " + howlong + "s" + " at " + where);
                 } else {
                     m = MessageQueue.currentlyPerforming;
                     t = System.currentTimeMillis();