[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/ref ExternalRef.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Wed, 3 Oct 2001 14:05:28 -0400
markm 01/10/03 14:05:28
Modified: src/jsrc/net/vattp/data DataCommThunk.java
src/jsrc/org/erights/e/elang/interp InteractiveInterp.java
Interp.java
src/jsrc/org/erights/e/elib/prim NowRunnable.java
Runner.java
src/jsrc/org/erights/e/elib/ref ExternalRef.java
Log:
Fixed ExternalRef missing argument bug.
Killed Runner.callNow()
Changed 'Object Runner.now(Thunk)' to
'void Runner.now(Runnable)'.
Revision Changes Path
1.5 +10 -10 e/src/jsrc/net/vattp/data/DataCommThunk.java
Index: DataCommThunk.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/vattp/data/DataCommThunk.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DataCommThunk.java 2001/10/02 01:29:18 1.4
+++ DataCommThunk.java 2001/10/03 18:05:28 1.5
@@ -34,7 +34,7 @@
*
* @author Bill Frantz
*/
-/*package*/ class DataCommThunk implements Thunk {
+/*package*/ class DataCommThunk implements Runnable {
static private final int NOTICE_PROBLEM = 1;
static private final int SHUT_DOWN_FINISHED = 2;
static private final int SEND_FINISHED = 3;
@@ -180,34 +180,34 @@
* Normally called by Runner's now method after it has acquired
* the Vat lock.
*/
- public Object run() {
+ public void run() {
switch (type) {
case NOTICE_PROBLEM:
myDataPath.noticeProblem(myException);
- return null;
+ return;
case SHUT_DOWN_FINISHED:
myDataPath.shutDownFinished(myMessage, myException);
- return null;
+ return;
case SEND_FINISHED:
myDataPath.sendFinished(myWrittenCount,
myWrittenLength, myContinuation);
- return null;
+ return;
case NEW_INCOMING_MSG:
myDataPath.newIncomingMsg(myMessage);
- return null;
+ return;
case ACCEPT_RECEIVER:
myDataPath.acceptReceiver(myRecvThread,
myRemoteNetAddr, myLocalNetAddr);
- return null;
+ return;
case NOTICE_PROBLEM_CM:
myConnMgr.noticeProblem(myException);
- return null;
+ return;
case INCOMING_SOCKET:
myConnMgr.newInboundSocket(mySocket);
- return null;
+ return;
case SEND_PROGRESS:
myDataPath.recordSendProgress();
- return null;
+ return;
default:
Trace.comm.errorm("Invalid type value=" + type);
throw new Error("Invalid type value=" + type);
1.11 +5 -4 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- InteractiveInterp.java 2001/09/14 01:35:22 1.10
+++ InteractiveInterp.java 2001/10/03 18:05:28 1.11
@@ -33,8 +33,10 @@
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.E;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
+import org.erights.e.elib.ref.ExternalRef;
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.ConstMap;
import org.erights.e.elib.tables.Twine;
@@ -79,7 +81,7 @@
private TextWriter myOuts;
private TextWriter myErrs;
- private Runner myRunner;
+ private ExternalRef myFarSelf;
private EParser myParser;
private Scope[] myTopPov;
@@ -120,7 +122,7 @@
myOuts = outs;
myErrs = errs;
- myRunner = runner;
+ myFarSelf = new ExternalRef(runner, this);
myParser = parser;
myTopPov = topPov;
@@ -388,8 +390,7 @@
EExpr optExpr = (EExpr)myParser.optParse();
if (null != optExpr) {
optExpr = optExpr.substitute(SubstArgs);
- Object[] args = { optExpr };
- myRunner.callNow(this, "evalPrint", args);
+ E.call(myFarSelf, "evalPrint", optExpr);
}
} catch (Throwable t) {
Throwable leaf = ThrowableSugar.leaf(t);
1.73 +5 -4 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.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- Interp.java 2001/09/14 01:35:22 1.72
+++ Interp.java 2001/10/03 18:05:28 1.73
@@ -34,8 +34,10 @@
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.prim.E;
import org.erights.e.elib.ref.Ref;
import org.erights.e.elib.ref.Resolver;
+import org.erights.e.elib.ref.ExternalRef;
import org.erights.e.elib.tables.ConstList;
import org.erights.e.elib.tables.ConstMap;
import org.erights.e.elib.tables.Twine;
@@ -90,7 +92,7 @@
private TextWriter myOuts;
private TextWriter myErrs;
- private Runner myRunner;
+ private ExternalRef myFarSelf;
private EParser myParser;
private Scope[] myTopPov;
@@ -125,7 +127,7 @@
myOuts = outs;
myErrs = errs;
- myRunner = runner;
+ myFarSelf = new ExternalRef(runner, this);
myParser = parser;
myTopPov = topPov;
@@ -431,8 +433,7 @@
try {
EExpr optExpr = (EExpr)myParser.optParse();
if (null != optExpr) {
- Object[] args = { optExpr };
- myRunner.callNow(this, "evalPrint", args);
+ E.call(myFarSelf, "evalPrint", optExpr);
}
} catch (Throwable t) {
reportProblem(t);
1.4 +11 -18 e/src/jsrc/org/erights/e/elib/prim/NowRunnable.java
Index: NowRunnable.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/NowRunnable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NowRunnable.java 2001/08/29 00:20:17 1.3
+++ NowRunnable.java 2001/10/03 18:05:28 1.4
@@ -25,9 +25,9 @@
import org.erights.e.elib.base.Thunk;
/**
- * Used for Runner.now() and Runner.callNow(). <p>
+ * Used for Runner.now(). <p>
*
- * @see Runner#now(Thunk)
+ * @see Runner#now(Runnable)
* @author E-Dean Tribble
* @author Mark S. Miller
*/
@@ -43,26 +43,20 @@
*
* Iff null, then we assume the thunk has been executed.
*/
- private Thunk myOptTodo;
+ private Runnable myOptTodo;
/**
* If myOptTodo threw a problem, then this is the problem. <p>
*
- * Meaningful iff null == myOptTodo. If null, then myResult is the
- * successful return value.
+ * Meaningful iff null == myOptTodo. If myOptProblem is also null, then
+ * myOptTodo completed successfully.
*/
private Throwable myOptProblem;
/**
- * Meaningfull iff null == myOptTodo && null == myOptProblem, in which
- * case it's the value successfully returned by myOptTodo's execution.
- */
- private Object myResult;
-
- /**
*
*/
- /*package*/ NowRunnable(Thunk todo) {
+ /*package*/ NowRunnable(Runnable todo) {
myOptTodo = todo;
}
@@ -70,11 +64,11 @@
* Called in the thread doing the now() or callNow(). <p>
*
* Schedules the execution of myOptTodo as a turn of the RunnerThread.
- * Blocks until that thunk completes in the RunnerThread, at which point
- * the outcome of myOptTodo becomes the outcome of the runFrom() (and
- * therefore the outcome of the now() or callNow()).
+ * Blocks until myOptTodo completes in the RunnerThread, at which point
+ * the outcome of myOptTodo becomes the outcome of the runNow(), and
+ * therefore the outcome of now().
*/
- /*package*/ Object runNow() {
+ /*package*/ void runNow() {
synchronized (myLock) {
while (null != myOptTodo) {
try {
@@ -87,7 +81,6 @@
if (null != myOptProblem) {
throw ExceptionMgr.asSafe(myOptProblem);
}
- return myResult;
}
/**
@@ -95,7 +88,7 @@
*/
public void run() {
try {
- myResult = myOptTodo.run();
+ myOptTodo.run();
} catch (Throwable problem) {
//XXX should this catch all Throwables or only Exceptions?
myOptProblem = problem;
1.29 +15 -20 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.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Runner.java 2001/09/14 01:35:22 1.28
+++ Runner.java 2001/10/03 18:05:28 1.29
@@ -149,13 +149,13 @@
}
/**
- * Schedules a thunk to execute in a Vat (in the RunnerThread as a
- * separate turn while holding the VatLock), while also effectively
- * executing as a synchronous call within the requestors's thread.
+ * Schedules a Runnable to execute in a Vat (in the RunnerThread as a
+ * separate turn), while also effectively executing as a synchronous call
+ * within the requestors's thread.
* <p>
* In most ways this can be thought of as a symmetric rendezvous between
- * the two Threads. The reason we *specify* that the thunk is executed
- * specifically in the requested Vat's RunnerThread is so that
+ * the two Threads. The reason we *specify* that the Runnable is
+ * executed specifically in the requested Vat's RunnerThread is so that
* thread-scoped state, such as Runner.currentRunner(), will be according
* to the Runner receiving the now() request, not whatever thread made
* the request.
@@ -168,27 +168,22 @@
* If this is invoked from within the runner thread that it would
* schedule todo on, then, to avoid a deadlock (thanks Dean!), we simply
* invoke todo synchronously instead.
+ * <p>
+ * If todo throws a problem rather than successfully returning, then
+ * now() rethrows that problem as well.
+ * <p>
+ * now() is for simple uses. When it doesn't fit, use
+ * {@link org.erights.e.elib.ref.ExternalRef#callAll(String, Object[])}
+ * instead
*/
- public Object now(Thunk todo) {
+ public void now(Runnable todo) {
if (isCurrentThreadInVat()) {
- return todo.run();
+ todo.run();
} else {
NowRunnable nr = new NowRunnable(todo);
enqueue(nr);
- return nr.runNow();
+ nr.runNow();
}
- }
-
- /**
- * Does a now() around <pre>
- * E.callAll(rec, verb, args)
- * </pre>
- * The outcome of callNow() is the outcome of the E.callAll().
- *
- * @see org.erights.e.elib.prim.Runner#now
- */
- public Object callNow(Object rec, String verb, Object[] args) {
- return now(new CallThunk(rec, verb, args));
}
/**
1.2 +1 -1 e/src/jsrc/org/erights/e/elib/ref/ExternalRef.java
Index: ExternalRef.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/ExternalRef.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExternalRef.java 2001/10/03 15:18:29 1.1
+++ ExternalRef.java 2001/10/03 18:05:28 1.2
@@ -138,7 +138,7 @@
} else {
//called from outside my target's vat's thread
Waiter waiter = new Waiter();
- Object[] args = { waiter };
+ Object[] args = { myTarget, waiter };
myTargetsRunner.sendAllOnly(Ref.RefMaker,
"whenResolvedOnly",
args);