You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ko...@apache.org on 2006/01/28 20:04:52 UTC
svn commit: r373217 - in
/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow:
Continuation.java bytecode/ContinuationDeath.java bytecode/StackRecorder.java
Author: kohsuke
Date: Sat Jan 28 11:04:48 2006
New Revision: 373217
URL: http://svn.apache.org/viewcvs?rev=373217&view=rev
Log:
implemented Continuation.exit()
Added:
jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java (with props)
Modified:
jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/Continuation.java
jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java
Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/Continuation.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/Continuation.java?rev=373217&r1=373216&r2=373217&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/Continuation.java (original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/Continuation.java Sat Jan 28 11:04:48 2006
@@ -17,6 +17,7 @@
import java.io.Serializable;
import org.apache.commons.javaflow.bytecode.StackRecorder;
+import org.apache.commons.javaflow.bytecode.ContinuationDeath;
import org.apache.commons.javaflow.utils.ReflectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -194,6 +195,18 @@
*/
public static void suspend() {
StackRecorder.suspend();
+ }
+
+ /**
+ * Exits the running continuation.
+ *
+ * <p>
+ * This method can be only called inside {@link #continueWith} or {@link #startWith} methods.
+ * When called, the thread returns from the above methods with null,
+ * indicating that there's nothing more to continue.
+ */
+ public static void exit() {
+ throw new ContinuationDeath();
}
public String toString() {
Added: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java?rev=373217&view=auto
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java (added)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java Sat Jan 28 11:04:48 2006
@@ -0,0 +1,9 @@
+package org.apache.commons.javaflow.bytecode;
+
+/**
+ * This exception is used to signal that the continuation
+ * wants to exit the execution.
+ *
+ * @author Kohsuke Kawaguchi
+ */
+public class ContinuationDeath extends Error {}
Propchange: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/ContinuationDeath.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java?rev=373217&r1=373216&r2=373217&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java (original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/StackRecorder.java Sat Jan 28 11:04:48 2006
@@ -91,7 +91,12 @@
}
log.debug("calling runnable");
- runnable.run();
+ try {
+ runnable.run();
+ } catch (ContinuationDeath e) {
+ // the code inside wanted to exit.
+ return null;
+ }
if (isCapturing) {
if(isEmpty()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org