import java.util.*;
import org.xwt.util.*;
-import org.mozilla.javascript.*;
/**
* A singleton class (one instance per JVM) that implements a queue
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;
private static MessageQueueWatcher watcher = new MessageQueueWatcher();
// HACK for debugging purposes
- Function lastfunc = null;
+ Object lastfunc = null;
Message lastmessage = null;
/**
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.getCurrentFunctionSourceName((ThreadMessage)m);
what = "background thread";
+ } else if (m != null) {
+ where = org.xwt.js.JS.getCurrentFunctionSourceName(MessageQueue.singleton);
+ what = "event trap";
} else {
- cx = Context.getContextForThread(MessageQueue.singleton);
- what = Main.initializationComplete ? "trap" : "script";
- }
- if (Log.on) Log.log(this, "WARNING: executing same " + what + " for " + (System.currentTimeMillis() - t) / 1000 + "s" +
- " at " + cx.interpreterSourceFile + ":" + cx.interpreterLine);
+ where = org.xwt.js.JS.getCurrentFunctionSourceName(MessageQueue.singleton);
+ what = "script";
+ }
+ if (Log.on) Log.log(this, "note: executing same " + what +
+ " for " + (System.currentTimeMillis() - t) / 1000 + "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) { }
}
}
}