[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/prim AWTRunnerEvent.java SacrificialComponent.java AWTRunner.java Runner.java RunnerImpl.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Wed, 12 Sep 2001 20:07:47 -0400
markm 01/09/12 20:07:47
Modified: src/esrc/scripts eBrowser.e
src/jsrc/org/erights/e/elib/prim AWTRunner.java Runner.java
RunnerImpl.java
Added: src/jsrc/org/erights/e/elib/prim AWTRunnerEvent.java
SacrificialComponent.java
Log:
now in AWT event Q and lowest (repaint) priority. Thanks Dean.
Revision Changes Path
1.41 +12 -9 e/src/esrc/scripts/eBrowser.e
Index: eBrowser.e
===================================================================
RCS file: /cvs/e/src/esrc/scripts/eBrowser.e,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- eBrowser.e 2001/09/12 00:01:52 1.40
+++ eBrowser.e 2001/09/13 00:07:47 1.41
@@ -1005,16 +1005,19 @@
textPane setEditable(false)
eBrowser setStatus("Reformatting...")
outputPane setText("Reformatting...")
- try {
- textPane setText(PrettyFeeder pretty(getTwine()))
- textPane setEditable(true)
- eBrowser setStatus("Reformat Done.")
- outputPane setText("Reformat Done.")
- textPane setEditable(true)
- } catch problem {
- textPane setEditable(true)
- problemReporter(problem)
+ def after() {
+ try {
+ textPane setText(PrettyFeeder pretty(getTwine()))
+ textPane setEditable(true)
+ eBrowser setStatus("Reformat Done.")
+ outputPane setText("Reformat Done.")
+ textPane setEditable(true)
+ } catch problem {
+ textPane setEditable(true)
+ problemReporter(problem)
+ }
}
+ after <- ()
}
to linesChanged() {
configureUpdatedListPane(funcListPane, textModel getOutlineList())
1.2 +18 -2 e/src/jsrc/org/erights/e/elib/prim/AWTRunner.java
Index: AWTRunner.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/AWTRunner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AWTRunner.java 2001/09/08 22:59:21 1.1
+++ AWTRunner.java 2001/09/13 00:07:47 1.2
@@ -27,6 +27,7 @@
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
@@ -36,10 +37,13 @@
*/
/*package*/ final class AWTRunner extends Runner {
- static /*package*/ final Runner THE_ONE =
+ static /*package*/ final AWTRunner THE_ONE =
new AWTRunner("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.
@@ -66,7 +70,19 @@
*
*/
public void enqueue(Runnable todo) {
- EventQueue.invokeLater(todo);
+ //XXX would it be safe to cache this?
+ EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
myNextTicket++;
+ AWTRunnerEvent event = new AWTRunnerEvent(todo);
+ q.postEvent(event);
+ }
+
+ /**
+ * Has an orderlyShutdown been requested?
+ * <p>
+ * The AWTRunner always says <code>false</code>
+ */
+ /*package*/ boolean isShuttingDown() {
+ return false;
}
}
1.27 +10 -33 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.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Runner.java 2001/09/08 22:59:21 1.26
+++ Runner.java 2001/09/13 00:07:47 1.27
@@ -73,11 +73,6 @@
/*package*/ long myNextTicket = 0;
/**
- * Has an orderly shutdown been requested?
- */
- private boolean myIsShuttingDown = false;
-
- /**
* Queue on which WeakPtrs are registered. Served by WeakPtrThread.
*/
private final ReferenceQueue myWeakPtrQueue;
@@ -100,14 +95,14 @@
*/
public abstract long servingTicket();
- /**
- * The ticket number to be "dispensed" to the next enqueued Runnable.
- * Ie, the ticket number that will be being served when this next
- * Runnable will be run(). May be used for causality tracing.
- */
- public long nextTicket() {
- return myNextTicket;
- }
+// /**
+// * The ticket number to be "dispensed" to the next enqueued Runnable.
+// * Ie, the ticket number that will be being served when this next
+// * Runnable will be run(). May be used for causality tracing.
+// */
+// public long nextTicket() {
+// return myNextTicket;
+// }
/**
*
@@ -197,25 +192,7 @@
}
/**
- * 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? Note that messages already
- * enqueued will still be serviced before the shutdown request is
- * honored.
+ * Has an orderlyShutdown been requested?
*/
- /*package*/ boolean isShuttingDown() {
- return myIsShuttingDown;
- }
+ /*package*/ abstract boolean isShuttingDown();
}
1.3 +29 -0 e/src/jsrc/org/erights/e/elib/prim/RunnerImpl.java
Index: RunnerImpl.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/prim/RunnerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RunnerImpl.java 2001/09/10 00:06:52 1.2
+++ RunnerImpl.java 2001/09/13 00:07:47 1.3
@@ -62,6 +62,11 @@
/*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.
@@ -158,5 +163,29 @@
}
}
}
+ }
+
+ /**
+ * 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/AWTRunnerEvent.java
Index: AWTRunnerEvent.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 AWTRunnerEvent
extends AWTEvent implements ActiveEvent {
/**
*
*/
private Runnable myTodo;
/**
*
*/
private long myTicket;
/**
*
*/
/*package*/ AWTRunnerEvent(Runnable todo) {
super(SacrificialComponent.THE_ONE, PaintEvent.PAINT);
myTodo = todo;
myTicket = AWTRunner.THE_ONE.myNextTicket;
}
/**
*
*/
public void dispatch() {
AWTRunner.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 {
AWTRunner.THE_ONE.myServingTicket = -1;
}
}
}
1.1 e/src/jsrc/org/erights/e/elib/prim/SacrificialComponent.java
Index: SacrificialComponent.java
===================================================================
package org.erights.e.elib.prim;
import java.awt.Component;
import java.awt.AWTEvent;
/*
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): ______________________________________.
*/
/**
* Exists just to be the do-nothing source of AWTRunnerEvents.
*
* @author <a href="mailto:markm@caplet.com">Mark S Miller</a>
* @author <a href="mailto:tstanley@cocoon.com">Terry Stanley</a>
*/
/*package*/ class SacrificialComponent extends Component {
/**
*
*/
static /*package*/ SacrificialComponent THE_ONE =
new SacrificialComponent();
/**
*
*/
private SacrificialComponent() {}
/**
*
*/
protected AWTEvent coalesceEvents(AWTEvent existingEvent,
AWTEvent newEvent) {
return null;
}
}