KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > kawa > lang > Continuation


1 package kawa.lang;
2 import gnu.mapping.*;
3
4 /**
5  * A Continuation "represents an entire (default) future for the computation.
6  * This implemementation is based on Java exceptions, and is restricted
7  * to "upward" (?) continuation (i.e. catch/throw-type uses).
8  * @author Per Bothner
9  */

10
11 public class Continuation extends MethodProc
12 {
13   public boolean invoked;
14   static int counter;
15   int id;
16
17   public Continuation (CallContext ctx)
18   {
19   }
20
21   public void apply (CallContext ctx)
22   {
23     if (invoked)
24       throw new GenericError
25     ("implementation restriction: continuation can only be used once");
26     throw new CalledContinuation (ctx.values, this);
27   }
28
29   public final String JavaDoc toString()
30   {
31     return "#<continuation " + id + (invoked ? " (invoked)>" : ">");
32   }
33 }
34
35
Popular Tags