[e-cvs] cvs commit: e/src/jsrc/org/erights/e/ui/elmer EInterpAdapter.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Thu, 13 Sep 2001 21:35:22 -0400
markm 01/09/13 21:35:22
Modified: src Makefile
src/csrc/setup eprops-template.txt
src/esrc/org/erights/e/elang/cmd cmdMakerMaker.emaker
src/esrc/scripts eBrowser.e evalServer.e evalServer.updoc
newlines.e setup.e updoc.e
src/jsrc/org/erights/e/elang/interp InteractiveInterp.java
Interp.java
src/jsrc/org/erights/e/elib/prim Runner.java
src/jsrc/org/erights/e/elib/tests TestMultiQMain.java
src/jsrc/org/erights/e/ui/elmer EInterpAdapter.java
Added: src/jsrc/org/erights/e/elib/prim BERunner.java FERunner.java
FERunnerEvent.java
Removed: src/jsrc/org/erights/e/elib/prim AWTRunner.java
AWTRunnerEvent.java RunnerImpl.java
Log:
Some renamings. evalServer generalized, but needs refactoring
Revision Changes Path
1.118 +3 -3 e/src/Makefile
Index: Makefile
===================================================================
RCS file: /cvs/e/src/Makefile,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- Makefile 2001/09/12 00:01:50 1.117
+++ Makefile 2001/09/14 01:35:21 1.118
@@ -6,9 +6,9 @@
default: draft explain
# Prefix tagging this release's attributes
-PREFIX=tl-E
-DOTVER=0.8.9zq
-TAGVER=0_8_9zq
+PREFIX=E
+DOTVER=0.8.10alpha1
+TAGVER=0_8_10alpha1
RELEASE=working
TOP=..
1.20 +4 -0 e/src/csrc/setup/eprops-template.txt
Index: eprops-template.txt
===================================================================
RCS file: /cvs/e/src/csrc/setup/eprops-template.txt,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- eprops-template.txt 2001/09/09 07:57:02 1.19
+++ eprops-template.txt 2001/09/14 01:35:21 1.20
@@ -229,6 +229,10 @@
e.interp.verbose=${{e.interp.verbose}}
+#
+
+e.interp.runner=${{e.interp.runner}}
+
################# Configuring a Vat's network presence #################
1.6 +79 -50 e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.emaker
Index: cmdMakerMaker.emaker
===================================================================
RCS file: /cvs/e/src/esrc/org/erights/e/elang/cmd/cmdMakerMaker.emaker,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cmdMakerMaker.emaker 2001/09/09 07:57:02 1.5
+++ cmdMakerMaker.emaker 2001/09/14 01:35:21 1.6
@@ -23,62 +23,91 @@
}
class cmdMakerMaker(cmdLoop, outBuf, errBuf) :any {
- class cmdMaker(sourceCode) :any {
- def [reportVow, reportRes] := PromiseMaker()
- def cmd() {
- def [tw, sb] := TextWriterMaker makeBufferingPair()
- def pov := cmdLoop getTopPov()
- var success := true
- def result := try {
- # should deal with embedded $-holes as result[i]
- def expr := EParser(sourceCode)
- if (cmdLoop getExpand()) {
- commentBlock(tw, "expansion", expr)
- }
- expr eval(pov)
- } catch problem {
- success := false
- Ref broken(problem)
- }
- cmdLoop pushResult(result)
- takeBuf(tw, "stdout", outBuf)
- takeBuf(tw, "stderr", errBuf)
- if (success) {
- if (result != null) {
- commentBlock(tw, "value") quote(result)
- tw println()
- tw println()
- }
- } else {
- def problem := Ref optProblem(result)
- def leaf := problem leaf()
- tw indent("# ") print("# ", leaf)
- def showJ := cmdLoop getShowsJavaStack()
- def showE := cmdLoop getShowsEStack()
- if (showJ || showE) {
- tw lnPrint("#")
+ # XXX Rather than textFlag, we should make two separate methods or objects
+ def cmdMaker {
+ to newValuer(sourceCode) :any {
+ def [resultVow, resultRes] := PromiseMaker()
+ def cmdValuer() {
+ def pov := cmdLoop getTopPov()
+ var success := true
+ def result := try {
+ # should deal with embedded $-holes as result[i]
+ def expr := EParser(sourceCode)
+ expr eval(pov)
+ } catch problem {
+ success := false
+ Ref broken(problem)
}
- if (showJ) {
- tw indent("# ") lnPrint(leaf javaStack())
+ cmdLoop pushResult(result)
+ if (success) {
+ # in order to distinguish a successfully returned broken
+ # ref from a thrown problem for a disconnect. Also, to enable
+ # detection of a successfully returned unresolved reference
+ resultRes resolve([result, true])
+ } else {
+ resultRes resolve([result, false])
}
- if (showE) {
- tw indent("# ") print(problem eStack())
+ }
+ when (cmdLoop getExitPairVow()) -> done([exitCode, optProblem]) {
+ if (null == optProblem) {
+ resultRes smash(`after normal exit: $exitCode`)
+ } else {
+ resultRes smash(optProblem)
}
- tw println()
- tw println()
+ } catch problem {
+ resultRes smash(problem)
}
- reportRes resolve(sb toString())
- sb setLength(0)
+ [resultVow, cmdValuer]
}
- when (cmdLoop getExitPairVow()) -> done([exitCode, optProblem]) {
- if (null == optProblem) {
- reportRes smash(`after normal exit: $exitCode`)
- } else {
- reportRes smash(optProblem)
+ to newReporter(sourceCode) :any {
+ def [reportVow, reportRes] := PromiseMaker()
+ def [resultVow, cmdValuer] := cmdMaker newValuer(sourceCode)
+ def cmdReporter() {
+ def [tw, sb] := TextWriterMaker makeBufferingPair()
+ # should deal with embedded $-holes as result[i]
+ if (cmdLoop getExpand()) {
+ def expr := EParser(sourceCode)
+ commentBlock(tw, "expansion", expr)
+ }
+ cmdValuer()
+ takeBuf(tw, "stdout", outBuf)
+ takeBuf(tw, "stderr", errBuf)
+ switch (resultVow) {
+ match [result, ==true] {
+ if (result != null) {
+ commentBlock(tw, "value") quote(result)
+ tw println()
+ tw println()
+ }
+ reportRes resolve(sb toString())
+ sb setLength(0)
+ }
+ match [result, ==false] {
+ def problem := Ref optProblem(result)
+ def leaf := problem leaf()
+ tw indent("# ") print("# ", leaf)
+ def showJ := cmdLoop getShowsJavaStack()
+ def showE := cmdLoop getShowsEStack()
+ if (showJ || showE) {
+ tw lnPrint("#")
+ }
+ if (showJ) {
+ tw indent("# ") lnPrint(leaf javaStack())
+ }
+ if (showE) {
+ tw indent("# ") print(problem eStack())
+ }
+ tw println()
+ tw println()
+ reportRes resolve(sb toString())
+ sb setLength(0)
+ }
+ match broke ? Ref isBroken(broke) {
+ reportRes resolve(broke)
+ }
+ }
}
- } catch problem {
- reportRes smash(problem)
+ [reportVow, cmdReporter]
}
- [reportVow, cmd]
}
}
1.42 +8 -6 e/src/esrc/scripts/eBrowser.e
Index: eBrowser.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/eBrowser.e,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- eBrowser.e 2001/09/13 00:07:47 1.41
+++ eBrowser.e 2001/09/14 01:35:21 1.42
@@ -306,6 +306,7 @@
def programRunner(sourceTwine, textPane, textModel, resultPane, statusPane) {
resultPane setText("Executing...")
+ statusPane setText("Executing...")
traceln("in runner, about to interpret")
def path := textModel getFilePath()
def textSelector := textSelectorMaker new(textPane, `file:$path`)
@@ -340,7 +341,8 @@
traceln("made tree")
def result := tree eval(scope2 newPov())
traceln("Interpretation done")
- resultPane append("\n# value: " + result)
+ resultPane setText("Execution ended:\n# value: " + result)
+ statusPane setText("Execution ended")
traceln("shown")
} catch problem {
@@ -348,7 +350,7 @@
}
}
- interpret()
+ interpret <- run()
}
# Compare the selection in a listpane to the items in a list
@@ -463,16 +465,16 @@
uiTools newButton(name,runner)
}
def newToolButton(uri, tipText, operation, target) :any {
- def runner() {
+ def actionFunc() {
E send(target, operation, [])
}
- uiTools newToolButton(uri, tipText ,runner)
+ uiTools newToolButton(uri, tipText ,actionFunc)
}
def addMenuItem(menu, name, operation, target) :any {
- def runner() {
+ def actionFunc() {
E send(target, operation, [])
}
- uiTools addMenuItem(menu, name,runner)
+ uiTools addMenuItem(menu, name,actionFunc)
}
def icons__uriGetter {
to get(name) :any {
1.4 +13 -2 e/src/esrc/scripts/evalServer.e
Index: evalServer.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/evalServer.e,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- evalServer.e 2001/09/07 05:49:19 1.3
+++ evalServer.e 2001/09/14 01:35:21 1.4
@@ -31,10 +31,21 @@
def cmdMaker := cmdMakerMaker new(cmdLoop, altoutBuf, alterrBuf)
def scriptEvaluator {
- to evalCmdVow(sourceCode) :any {
- def [reportVow, cmd] := cmdMaker new(sourceCode)
+ # Schedules sourceCode to be evaluated as the next top level command
+ # in the scriptEvaluator's currents (at that time) scope, and
+ # returns a vow for a textual report of the outcome
+ to evalCmdReportVow(sourceCode) :any {
+ def [reportVow, cmd] := cmdMaker newReporter(sourceCode)
cmdLoop enqueue(cmd)
reportVow
+ }
+ # Schedules sourceCode to be evaluated as the next top level command
+ # in the scriptEvaluator's currents (at that time) scope, and
+ # returns a vow for an object representing the outcome
+ to evalCmdValueVow(sourceCode) :any {
+ def [valueVow, cmd] := cmdMaker newValuer(sourceCode)
+ cmdLoop enqueue(cmd)
+ valueVow
}
to getCmdLoop() :any { cmdLoop }
}
1.4 +17 -8 e/src/esrc/scripts/evalServer.updoc
Index: evalServer.updoc
===================================================================
RCS file: /cvs/e/src/esrc/scripts/evalServer.updoc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- evalServer.updoc 2001/08/24 17:14:02 1.3
+++ evalServer.updoc 2001/09/14 01:35:21 1.4
@@ -1,28 +1,37 @@
? introducer onTheAir()
-# value: ["3DES_SDH_M"]
+# value: ["3DES_SDH_M2", "3DES_SDH_M"]
-? def sr := <cap://192.168.0.21:1385;63.178.231.220:1385/6BoBqEMMnqCNwHEQNclG5O5a8Nq/Cg_dzihfAveXfXwEIjJNhjLucSC>
+? def sr := <cap://192.168.0.21:1043/5UmFAqXbepvCOwuSHCEGHt5V1wC/Ray1=9hgEHkC8i_DRs5WKfsLnji>
# value: <SturdyRef>
-? def evalServerPass := sr liveRef()
+? def evalServerRcvr := sr liveRef()
# value: <Eventual ref>
-? def sePass1 := evalServerPass <- newScriptEvaluator(["se1", "arg"])
+? evalServerRcvr
# value: <Eventual ref>
-?
-? def r1 := sePass1 <- evalCmdVow("2 + 3")
+? def seRcvr1 := evalServerRcvr <- newScriptEvaluator(["se1", "arg"])
+# value: <Eventual ref>
+
+? def r1 := seRcvr1 <- evalCmdReportVow("2 + 3")
# value: <Eventual ref>
? r1
-# value: "# valuex: 5\n\
+# value: "# value: 5\n\
# \n\
# "
? println(r1)
-# valuex: 5
+# value: 5
+? def v1 := seRcvr1 <- evalCmdValueVow("2 + 3")
+# value: <Eventual ref>
+
+? v1
+# value: [5, true]
+
+?
? def r2 := sePass1 <- evalCmdVow(`println("Hello world")`)
# value: <Eventual ref>
1.22 +1 -0 e/src/esrc/scripts/newlines.e
Index: newlines.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/newlines.e,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- newlines.e 2001/08/13 21:03:21 1.21
+++ newlines.e 2001/09/14 01:35:21 1.22
@@ -32,6 +32,7 @@
"xml" => true,
"emaker" => true,
"updoc" => true,
+ "caplet" => true,
"java" => true,
"y" => true,
"sh" => true,
1.16 +1 -0 e/src/esrc/scripts/setup.e
Index: setup.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/setup.e,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- setup.e 2001/09/09 07:57:02 1.15
+++ setup.e 2001/09/14 01:35:21 1.16
@@ -18,6 +18,7 @@
"e.interp.parseSpam" => "false",
"e.interp.expand" => "false",
"e.interp.verbose" => "false",
+ "e.interp.runner" => "fe",
"e.enable.anon-lambda" => "false",
"e.enable.auditors" => "false",
"e.enable.bind" => "true",
1.14 +1 -1 e/src/esrc/scripts/updoc.e
Index: updoc.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/updoc.e,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- updoc.e 2001/09/10 00:06:51 1.13
+++ updoc.e 2001/09/14 01:35:21 1.14
@@ -127,7 +127,7 @@
}
to newReportVow(scriptEvaluatorRcvr) :any {
- scriptEvaluatorRcvr <- evalCmdVow(expr)
+ scriptEvaluatorRcvr <- evalCmdReportVow(expr)
}
to report(newReport, out) {
1.10 +2 -1 e/src/jsrc/org/erights/e/elang/interp/InteractiveInterp.java
Index: InteractiveInterp.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/InteractiveInterp.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- InteractiveInterp.java 2001/09/10 00:06:51 1.9
+++ InteractiveInterp.java 2001/09/14 01:35:22 1.10
@@ -32,6 +32,7 @@
import org.erights.e.elang.syntax.NeedMoreException;
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.prim.Runner;
+import org.erights.e.elib.prim.FERunner;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
import org.erights.e.elib.tables.ConstList;
@@ -532,7 +533,7 @@
outs,
errs,
- Runner.uiRunner(),
+ FERunner.THE_ONE,
null, //optLineFeeder
null, //optTopScope
false); //partialFlag
1.72 +19 -1 e/src/jsrc/org/erights/e/elang/interp/Interp.java
Index: Interp.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elang/interp/Interp.java,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- Interp.java 2001/09/10 00:06:51 1.71
+++ Interp.java 2001/09/14 01:35:22 1.72
@@ -32,6 +32,8 @@
import org.erights.e.elang.syntax.LineFeeder;
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.prim.Runner;
+import org.erights.e.elib.prim.FERunner;
+import org.erights.e.elib.prim.BERunner;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
import org.erights.e.elib.tables.ConstList;
@@ -517,6 +519,10 @@
if (uiInititialized) {
return;
}
+ String runnerType = (String)props.get("e.interp.runner", "fe");
+ if (! runnerType.equals("fe")) {
+ return;
+ }
uiInititialized = true;
String lf = (String)props.get("e.swingLnF", "platform");
@@ -653,6 +659,18 @@
}
ConstMap props = ConstMap.fromProperties(sysProps);
+
+ String runnerType = (String)props.get("e.interp.runner", "fe");
+ Runner runner;
+ if (runnerType.equals("fe")) {
+ runner = FERunner.THE_ONE;
+ } else if (runnerType.equals("be")) {
+ runner = new BERunner("Main BE");
+ } else {
+ throw new RuntimeException("unrecognized e.interp.runner=" +
+ runnerType);
+ }
+
Interp interp = null;
try {
interp = Interp.make(args,
@@ -660,7 +678,7 @@
outs,
errs,
- Runner.uiRunner(),
+ runner,
null, //optLineFeeder
null); //optTopScope
} catch (Throwable th) {
1.28 +5 -5 e/src/jsrc/org/erights/e/elib/prim/Runner.java
Index: Runner.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/Runner.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- Runner.java 2001/09/13 00:07:47 1.27
+++ Runner.java 2001/09/14 01:35:22 1.28
@@ -37,17 +37,17 @@
public abstract class Runner {
/**
- *
+ * @deprecated Just call 'FERunner.THE_ONE' directly
*/
static public Runner uiRunner() {
- return AWTRunner.THE_ONE;
+ return FERunner.THE_ONE;
}
/**
- *
+ * @deprecated Just call 'new BERunner(name)' directly
*/
static public Runner newHeadless(String name) {
- return new RunnerImpl(name);
+ return new BERunner(name);
}
/**
@@ -60,7 +60,7 @@
return (Runner)((RunnerThread)t).myRunnable;
}
if (EventQueue.isDispatchThread()) {
- return AWTRunner.THE_ONE;
+ return FERunner.THE_ONE;
}
throw new RuntimeException("Must be in a vat");
}
1.1 e/src/jsrc/org/erights/e/elib/prim/BERunner.java
Index: BERunner.java
===================================================================
package org.erights.e.elib.prim;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import org.erights.e.develop.trace.Trace;
import org.erights.e.elib.base.Thunk;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
import org.erights.e.elib.ref.ResultResolver;
import java.lang.ref.ReferenceQueue;
/**
* Runs when it can, but never on empty. A thread services a queue
* of Runnables.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
* @author Many improvements due to suggestions by E-Dean Tribble
*/
public final class BERunner extends Runner implements Runnable {
/**
* The number of Runnables to dequeue and run in one go.
* Must be >= 1.
*/
static private int DEQUEUE_GRANULARITY = 25;
/**
* Note that SynchQueue is a thread-safe data structure with its own lock.
*/
private SynchQueue myQ;
/**
* If we ever go orthogonal again, myThread must not be
* checkpointed. Ie, it must be a DISALLOWED_FIELD or 'transient'
* or something.
*/
private transient RunnerThread myThread;
/**
* The ticket number of the Runnable currently being run() (or, if
* we're idle, the one that has just been run()). Used for causality
* tracing.
*/
/*package*/ long myServingTicket = -1;
/**
* Has an orderly shutdown been requested?
*/
private boolean myIsShuttingDown = false;
/**
* Makes a Runner, and starts the thread that services its queue.
*
* @param name is the name to give to the thread created.
*/
public BERunner(String name) {
super(name);
myQ = new SynchQueue(Runnable.class);
myThread = new RunnerThread(this, name);
myThread.start();
}
/**
* Adjusts the priority of the RunnerThread.
* <p>
* Just delegates to {@link Thread#setPriority(int)}
*/
public void setPriority(int newPriority) {
myThread.setPriority(newPriority);
}
/**
*
*/
public long servingTicket() {
return myServingTicket;
}
/**
*
*/
public boolean isCurrentThreadInVat() {
return Thread.currentThread() == myThread;
}
/**
* Performs a Thread.stop(t) on the thread executing the current
* event. <p>
*
* Note that Thread.stop() does not stop the thread (obvious huh?), but
* rather causes that thread to experience a "spontaneously" thrown
* exception.
*
* @deprecated Since Thread.stop() is also deprecated, but will be
* available as long as Thread.stop() remains available.
* @see java.lang.Thread#stop
*/
public void disturbEvent(Throwable t) {
myThread.stop(t);
}
/**
*
*/
public void enqueue(Runnable todo) {
//enqueueing is guarded by the queue's lock, not the vatLock.
myQ.enqueue(todo);
myNextTicket++;
}
/**
* Called only by Thread.start(). <p>
*
* (XXX It's a modularity bug for this to be public.) Pulls Runnables off
* of the queue until there aren't any more, then waits until there's
* more to do.
*/
public void run() {
while (true) {
try {
Thread.yield();
//within each chunk, wait if necessary for the first one.
Runnable todo = (Runnable)myQ.dequeue();
int i = DEQUEUE_GRANULARITY;
while (null != todo) {
myServingTicket++;
todo.run();
if (i <= 0) {
break;
}
i--;
todo = (Runnable)myQ.optDequeue();
}
} catch (ShutDownVatException sdve) {
//this kludge is the least painful way I could think
//of to do an orderly Scott-like shutdown (as in
//Scott's queue class) of a vat thread without
//imposing *any* extra overhead on the normal case.
return;
} catch (Throwable t) {
if (Trace.causality.error) {
Trace.causality.errorReportException(t,
"Exception made it all the way out of the run " +
"loop. Restarting it.");
}
}
}
}
/**
* Will enqueue a request to shut down this vat's thread. Since
* this is an enqueued request, the thread will only shut down
* after finishing earlier requests, as well as any now()s that
* happen in the meantime. For a more violent approach, see
* disturbEvent().
*
* @see org.erights.e.elib.prim.Runner#disturbEvent
*/
public void orderlyShutdown() {
enqueue(new ShutDownVatException());
myIsShuttingDown = true;
}
/**
* Has an orderlyShutdown been requested?
* <p>
* Note that messages already enqueued will still be serviced before the
* shutdown request is honored.
*/
/*package*/ boolean isShuttingDown() {
return myIsShuttingDown;
}
}
1.1 e/src/jsrc/org/erights/e/elib/prim/FERunner.java
Index: FERunner.java
===================================================================
package org.erights.e.elib.prim;
/*
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import org.erights.e.develop.trace.Trace;
import org.erights.e.elib.base.Thunk;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
import org.erights.e.elib.ref.ResultResolver;
import java.lang.ref.ReferenceQueue;
import java.awt.EventQueue;
import java.awt.Toolkit;
/**
* Uses the AWT Event Thread as a virtual RunnerThread, so that Swing can be
* "in" this vat.
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
public final class FERunner extends Runner {
static public final FERunner THE_ONE =
new FERunner("AWT Runner");
/**
/*package*/ long myServingTicket = -1;
/**
* Makes a Runner, and starts the thread that services its queue.
*
* @param name is the name to give to the thread created.
*/
private FERunner(String name) {
super(name);
}
/**
*
*/
public boolean isCurrentThreadInVat() {
return EventQueue.isDispatchThread();
}
/**
*
*/
public long servingTicket() {
return -1; //XXX for now
}
/**
*
*/
public void enqueue(Runnable todo) {
//XXX would it be safe to cache this?
EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
myNextTicket++;
FERunnerEvent event = new FERunnerEvent(todo);
q.postEvent(event);
}
/**
* Has an orderlyShutdown been requested?
* <p>
* The FERunner always says <code>false</code>
*/
/*package*/ boolean isShuttingDown() {
return false;
}
}
1.1 e/src/jsrc/org/erights/e/elib/prim/FERunnerEvent.java
Index: FERunnerEvent.java
===================================================================
package org.erights.e.elib.prim;
/*
The contents of this file are subject to the Improvements to the
Distributed E Language Implementation License Version 1.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.erights.org/download/mmlicense.html
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
The Original Code is the Improvements to the Distributed E Language
Implementation, released May 27, 1999.
The Initial Developer of the Original Code is Mark S. Miller.
Copyright (C) 1999 Mark S. Miller. All Rights Reserved.
Contributor(s): ______________________________________.
*/
import org.erights.e.develop.trace.Trace;
import java.awt.ActiveEvent;
import java.awt.AWTEvent;
import java.awt.event.PaintEvent;
/**
* For scheduling Runner events (vat turns) on the AWT Event Queue at the
* low priority, which is "supposed" to be for repaints.
*
* @author <a href="mailto:markm@caplet.com">Mark S Miller</a>
* @author <a href="mailto:tstanley@cocoon.com">Terry Stanley</a>
*/
/*package*/ class FERunnerEvent
extends AWTEvent implements ActiveEvent {
/**
*
*/
private Runnable myTodo;
/**
*
*/
private long myTicket;
/**
*
*/
/*package*/ FERunnerEvent(Runnable todo) {
super(SacrificialComponent.THE_ONE, PaintEvent.PAINT);
myTodo = todo;
myTicket = FERunner.THE_ONE.myNextTicket;
}
/**
*
*/
public void dispatch() {
FERunner.THE_ONE.myServingTicket = myTicket;
try {
myTodo.run();
} catch (Throwable t) {
if (Trace.causality.error) {
Trace.causality.errorReportException(t,
"Exception made it all the way out of the awt run " +
"loop. Continuing anyway.");
}
} finally {
FERunner.THE_ONE.myServingTicket = -1;
}
}
}
1.11 +3 -2 e/src/jsrc/org/erights/e/elib/tests/TestMultiQMain.java
Index: TestMultiQMain.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/tests/TestMultiQMain.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TestMultiQMain.java 2001/09/08 22:59:22 1.10
+++ TestMultiQMain.java 2001/09/14 01:35:22 1.11
@@ -22,6 +22,7 @@
import org.erights.e.develop.exception.PrintStreamWriter;
import org.erights.e.elib.prim.E;
import org.erights.e.elib.prim.Runner;
+import org.erights.e.elib.prim.BERunner;
import org.erights.e.elib.ref.DeviceRef;
/**
@@ -54,9 +55,9 @@
// Also, we'll specify the target object for each ref.
// Creating the new Runner instances also has the effect of creating
// and starting a thread for each Runner instance.
- DeviceRef ref1 = new DeviceRef(Runner.newHeadless("t1"),
+ DeviceRef ref1 = new DeviceRef(new BERunner("t1"),
target1);
- DeviceRef ref2 = new DeviceRef(Runner.newHeadless("t2"),
+ DeviceRef ref2 = new DeviceRef(new BERunner("t2"),
target2);
// Give the target2 DeviceRef to target1.
1.39 +2 -1 e/src/jsrc/org/erights/e/ui/elmer/EInterpAdapter.java
Index: EInterpAdapter.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/ui/elmer/EInterpAdapter.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- EInterpAdapter.java 2001/09/08 22:59:22 1.38
+++ EInterpAdapter.java 2001/09/14 01:35:22 1.39
@@ -28,6 +28,7 @@
import org.erights.e.elib.base.SourceSpan;
import org.erights.e.elib.eio.TextWriter;
import org.erights.e.elib.prim.Runner;
+import org.erights.e.elib.prim.FERunner;
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.ConstMap;
import org.erights.e.elib.tables.Twine;
@@ -79,7 +80,7 @@
myOuts,
myOuts, //errs
- Runner.uiRunner(),
+ FERunner.THE_ONE,
sacrificial, //never used, but suppresses
//filename processing
null, //optTopScope