Package kilim
Class Generator<T>
java.lang.Object
kilim.Continuation
kilim.Generator<T>
- All Implemented Interfaces:
Iterable<T>,Iterator<T>,Fiber.Worker
- Direct Known Subclasses:
Fib,Post,Pre,Xorshift.X1
A Generator, from the caller's perspective, looks like a normal iterator
that produces values. Because a standard iterator's next() method
must return every time, the programmer is forced to manage the stack
explicitly. The Generator class instead allows one to write a
task with an automatically managed stack and couple it to an
iterator interface.
For example:
class StringGenerator extends Generator{ public void execute() throws Pausable { while (!done) { String s = getNextWord(); // this can pause yield(s); } } private String getNextWord() throws Pausable { } }
-
Nested Class Summary
Nested classes/interfaces inherited from class kilim.Continuation
Continuation.FakeTask -
Field Summary
FieldsFields inherited from class kilim.Continuation
fakeTask -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
nextVal
T nextVal -
done
boolean done
-
-
Constructor Details
-
Generator
public Generator()
-
-
Method Details