E
- the element class that the Iterator returnspublic abstract class CoIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>, java.io.Serializable
Modifier | Constructor and Description |
---|---|
protected |
CoIterator() |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext() |
E |
next() |
protected void |
produce(E element)
Produces the next value to be returned by the
next() method. |
void |
remove()
Always throws UnsupportedOperationException.
|
protected abstract void |
run()
This is the body of the Iterator.
|
public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
public void remove() throws java.lang.UnsupportedOperationException
remove
in interface java.util.Iterator<E>
java.lang.UnsupportedOperationException
- alwaysprotected void produce(E element) throws SuspendExecution
next()
method.element
- The value that should be returned by next()
SuspendExecution
- This method will suspend the executionprotected abstract void run() throws SuspendExecution
This is the body of the Iterator. This method is executed as a
Coroutine
to produce(E)
the values of the Iterator.
Note that this method is suspended each time it calls produce. And if the consumer does not consume all values of the Iterator then this method does not get the change to finish it's execution. This also includes the finally blocks.
This method must only suspend by calling produce. Any other reason for suspension will cause a busy loop in the Iterator.
SuspendExecution