X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FMessageQueue.java;h=fbebad47ae9ca46a360c7927d68ab9442526227e;hb=b32cea3f3e272ab00899d134d75a8bd7bcf6c8c0;hp=1831dfc1bd11c6272c9bd128a4785146844a897f;hpb=c9e1bd707806233eefcaa5497a7a99a95ae3da51;p=org.ibex.core.git diff --git a/src/org/xwt/MessageQueue.java b/src/org/xwt/MessageQueue.java index 1831dfc..fbebad4 100644 --- a/src/org/xwt/MessageQueue.java +++ b/src/org/xwt/MessageQueue.java @@ -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 @@ -32,7 +31,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; @@ -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; /** @@ -68,7 +67,7 @@ public class MessageQueue extends Thread { i--; continue; } - working = true; + if (!(e instanceof Thread)) working = true; currentlyPerforming = e; // for debugging purposes @@ -115,24 +114,26 @@ 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.Context.getSourceNameAndLineForThread((ThreadMessage)m); what = "background thread"; + } else if (m != null) { + where = org.xwt.js.Context.getSourceNameAndLineForThread(MessageQueue.singleton); + what = "event trap"; } else { - cx = Context.getContextForThread(MessageQueue.singleton); - what = Main.initializationComplete ? "trap" : "script"; + where = org.xwt.js.Context.getSourceNameAndLineForThread(MessageQueue.singleton); + what = "script"; } - if (Log.on) Log.log(this, "WARNING: 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(); } - try { Thread.sleep(Main.initializationComplete ? 1000 : 15000); } catch (Exception e) { } + try { Thread.sleep(1000); } catch (Exception e) { } } } }