X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FThreadMessage.java;h=f4f95a923575689b0b5b46a1c19ac6482afb6c0e;hb=69ecee0bc41e6bd410572817e7c59d51f1b5b629;hp=bbd1f2461935a1d338a71494fb632bdf2a2cdc64;hpb=fcac36538ece60a2f6f8cc83e0dd26afc1df2c19;p=org.ibex.core.git
diff --git a/src/org/xwt/ThreadMessage.java b/src/org/xwt/ThreadMessage.java
index bbd1f24..f4f95a9 100644
--- a/src/org/xwt/ThreadMessage.java
+++ b/src/org/xwt/ThreadMessage.java
@@ -1,9 +1,9 @@
// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
package org.xwt;
-import org.xwt.util.*;
import java.util.*;
-import org.mozilla.javascript.*;
+import org.xwt.util.*;
+import org.xwt.js.*;
/**
* A background thread. All threads created with xwt.thread
@@ -20,7 +20,7 @@ public class ThreadMessage extends Thread implements Message {
private volatile static int threadcount = 0;
/** the JavaScript function that we are executing */
- volatile Function f;
+ volatile JS.Function f;
/** the ThreadMessage thread blocks on this before executing any JavaScript */
Semaphore go = new Semaphore();
@@ -38,7 +38,7 @@ public class ThreadMessage extends Thread implements Message {
private static Object[] emptyobj = new Object[] { };
/** creates a new thread to execute function f */
- public static synchronized void newthread(Function f) {
+ public static synchronized void newthread(JS.Function f) {
ThreadMessage ret = (ThreadMessage)spare.remove(false);
if (ret == null) {
if (threadcount < Platform.maxThreads()) ret = new ThreadMessage();
@@ -56,9 +56,7 @@ public class ThreadMessage extends Thread implements Message {
// put ourselves in the background
Thread thread = Thread.currentThread();
if (!(thread instanceof ThreadMessage)) {
- Context cx = Context.enter();
- if (Log.on) Log.log(ThreadMessage.class, "attempt to perform background-only operation in a foreground thread at " +
- cx.interpreterSourceFile + ":" + cx.interpreterLine);
+ if (Log.on) Log.log(ThreadMessage.class, "attempt to perform background-only operation in a foreground thread at " + JS.getCurrentFunctionSourceName());
return false;
}
ThreadMessage mythread = (ThreadMessage)thread;
@@ -78,22 +76,17 @@ public class ThreadMessage extends Thread implements Message {
public void run() {
try {
threadcount++;
- Context cx = Context.enter();
while (true) {
try {
go.block();
- f.call(cx, f.getParentScope(), f.getParentScope(), emptyobj);
- } catch (EcmaError e) {
- if (Log.on) Log.log(this, "WARNING: uncaught interpreter exception: " + e.getMessage());
- if (Log.on) Log.log(this, " thrown from background thread at " + e.getSourceName() + ":" + e.getLineNumber());
- } catch (JavaScriptException e) {
- if (Log.on) Log.log(this, "WARNING: uncaught ecmascript exception: " + e.getMessage());
- if (Log.on) Log.log(this, " thrown from background thread at " + e.sourceFile + ":" + e.line);
+ f.call(new JS.Array());
+ } catch (JS.Exn e) {
+ if (Log.on) Log.log(this, "WARNING: uncaught ecmascript exception: " + e);
}
done.release();
synchronized(waiting) {
if (waiting.size() > 0) {
- f = (Function)waiting.remove(false);
+ f = (JS.Function)waiting.remove(false);
MessageQueue.add(this);
} else if (spare.size() < 10) {
spare.append(this);