orc.runtime
Class Continuation

java.lang.Object
  extended by orc.runtime.Continuation

public class Continuation
extends java.lang.Object

A one-shot continuation which a site can use to resume a computation with a suspended value. Exists mainly to provide Java sites with a restricted interface to tokens to prevent them from doing anything bad.

Author:
quark

Constructor Summary
Continuation(Token token)
           
 
Method Summary
 void error(java.lang.Exception e)
          Signal an error.
 void error(TokenException e)
           
 void kill()
          Kill the continuation (indicate it will never return).
 void resume(Value value)
          Return a value from a site call.
static Continuation suspend()
          Get a continuation which can be used by a site to return a value to the Orc engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Continuation

public Continuation(Token token)
Method Detail

suspend

public static Continuation suspend()
Get a continuation which can be used by a site to return a value to the Orc engine. This may only be called by a site once during a site call, and it must be called by the thread that initiated the call.

Note that this does not block or perform any control flow; it's up to the caller to return normally after calling this method (though the return value will be ignored).


kill

public void kill()
Kill the continuation (indicate it will never return). May only be called once.


error

public void error(TokenException e)

error

public void error(java.lang.Exception e)
Signal an error. Well-behaved sites will call this instead of throwing an exception, to allow Orc to handle the error correctly.


resume

public void resume(Value value)
Return a value from a site call. May only be called once.

Note that this does not perform any control flow; the actual resumption will occur in a separate thread, so it's up to the caller what to do after resuming.