X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FThreadMessage.java;h=0eeefef2be93c2e29830a28366219575a69b1373;hb=16ea48d834626fb9815da2f7632c3633838fb790;hp=07a47d476532b36e880212b7388d0cbae273d96e;hpb=2fa20bbe798c44d0443d7b80d8dbcf7eb13fff4a;p=org.ibex.core.git diff --git a/src/org/xwt/ThreadMessage.java b/src/org/xwt/ThreadMessage.java index 07a47d4..0eeefef 100644 --- a/src/org/xwt/ThreadMessage.java +++ b/src/org/xwt/ThreadMessage.java @@ -1,4 +1,4 @@ -// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt; import java.util.*; @@ -16,7 +16,7 @@ import org.xwt.js.*; * this invariant. */ public class ThreadMessage extends Thread implements Message { - + private volatile static int threadcount = 0; /** the JavaScript function that we are executing */ @@ -25,7 +25,7 @@ public class ThreadMessage extends Thread implements Message { /** the ThreadMessage thread blocks on this before executing any JavaScript */ Semaphore go = new Semaphore(); - /** The MessageQueue (main) thread blocks on this while the ThreadMessage thread is running JavaScript code */ + /** The Message.Q (main) thread blocks on this while the ThreadMessage thread is running JavaScript code */ Semaphore done = new Semaphore(); /** used to pool ThreadMessages that are not in use */ @@ -48,7 +48,7 @@ public class ThreadMessage extends Thread implements Message { } } ret.f = f; - MessageQueue.add(ret); + Message.Q.add(ret); } /** attempts to put this thread into the background to perform a blocking operation; returns false if unable to do so */ @@ -56,7 +56,7 @@ public class ThreadMessage extends Thread implements Message { // put ourselves in the background Thread thread = Thread.currentThread(); if (!(thread instanceof ThreadMessage)) { - if (Log.on) Log.log(ThreadMessage.class, "attempt to perform background-only operation in a foreground thread at " + Context.getCurrentSourceNameAndLine()); + if (Log.on) Log.logJS(ThreadMessage.class, "attempt to perform background-only operation in a foreground thread"); return false; } ThreadMessage mythread = (ThreadMessage)thread; @@ -68,7 +68,7 @@ public class ThreadMessage extends Thread implements Message { /** re-enqueues this thread */ public static void resumeThread() { ThreadMessage mythread = (ThreadMessage)Thread.currentThread(); - MessageQueue.add(mythread); + Message.Q.add(mythread); mythread.setPriority(Thread.NORM_PRIORITY); mythread.go.block(); } @@ -87,7 +87,7 @@ public class ThreadMessage extends Thread implements Message { synchronized(waiting) { if (waiting.size() > 0) { f = (JS.Callable)waiting.remove(false); - MessageQueue.add(this); + Message.Q.add(this); } else if (spare.size() < 10) { spare.append(this); } else { @@ -104,7 +104,7 @@ public class ThreadMessage extends Thread implements Message { } } - /** this is invoked in the MessageQueue thread */ + /** this is invoked in the Message.Q thread */ public void perform() { go.release(); done.block();