Package kilim.examples
Class Fib
- java.lang.Object
-
- kilim.Continuation
-
- kilim.Generator<java.math.BigInteger>
-
- kilim.examples.Fib
-
- All Implemented Interfaces:
java.lang.Iterable<java.math.BigInteger>,java.util.Iterator<java.math.BigInteger>,Fiber.Worker
public class Fib extends Generator<java.math.BigInteger>
This example prints the nth Fibonacci number. It illustrates a generator, which is part iterator, part task. It returns the next object 'yielded' by its execute method. The difference between a generator and a task is that the former is invoked by the caller synchronously on the caller's stack; it is not scheduled in a separate thread.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class kilim.Continuation
Continuation.FakeTask
-
-
Constructor Summary
Constructors Constructor Description Fib()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()the top level entrypoint for the continuation override this method cannot be called directly - use run() instead use Fiber.yield() to yield control cooperatively and return execution to the caller of run()static voidmain(java.lang.String[] args)-
Methods inherited from class kilim.Continuation
ex, execute, reset, run
-
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
-
execute
public void execute() throws PausableDescription copied from class:Continuationthe top level entrypoint for the continuation override this method cannot be called directly - use run() instead use Fiber.yield() to yield control cooperatively and return execution to the caller of run()- Specified by:
executein interfaceFiber.Worker- Overrides:
executein classContinuation- Throws:
Pausable
-
-