pl.clareo.coroutines.user
Class Coroutines

java.lang.Object
  extended by pl.clareo.coroutines.user.Coroutines

public final class Coroutines
extends java.lang.Object

This class contains methods used when creating coroutine

Author:
Marcin Rzeźnicki

Constructor Summary
Coroutines()
           
 
Method Summary
static
<E,A> CoIterator<E,A>
_()
          Exit point of coroutine.
static
<A> A
yield()
          Yield point of coroutine.
static
<E,A> A
yield(E e)
          Yield point of coroutine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Coroutines

public Coroutines()
Method Detail

_

public static <E,A> CoIterator<E,A> _()
Exit point of coroutine. Coroutine creator may use it whenever return statement is needed. This statement throws NoSuchElementException in runtime or InvalidCoroutineException if used in non-coroutine method (it may be thrown if coroutine instrumentation fails)

Type Parameters:
E - anything
A - anything
Returns:
useless, used only to satisfy return statements

yield

public static <A> A yield()
Yield point of coroutine. In runtime it suspends coroutine execution and returns to caller.

Type Parameters:
A - type of yield's result
Returns:
if caller used send to resume coroutine execution it becomes result of yield

yield

public static <E,A> A yield(E e)
Yield point of coroutine. In runtime it suspends coroutine execution and returns e to caller

Type Parameters:
E - type of yielded value
A - type of yield's result
Parameters:
e - passed to caller
Returns:
if caller used send to resume coroutine execution it becomes result of yield


Copyright © 2010 CLAREO. All Rights Reserved.