|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--saffron.runtime.QueueIterator
QueueIterator
contains at most one object. If you call next()
, your thread will wait until another thread calls put(java.lang.Object)
or
done(java.lang.Throwable)
. Nulls are allowed. If the producer has an error, they can
pass it to the consumer via done(java.lang.Throwable)
.
Field Summary | |
private Semaphore |
empty
The producer notifies empty every time it produces an
object (or finishes). |
private Semaphore |
full
Conversely, the consumer notifies full every time
it reads the next object. |
private boolean |
hasNext_
|
private Object |
next_
|
private Throwable |
throwable_
|
private boolean |
waitingForProducer_
Protects the avail_ semaphore. |
Constructor Summary | |
(package private) |
QueueIterator()
|
Method Summary | |
private void |
checkError()
Throws an error if one has been set via done(Throwable) . |
void |
done(Throwable throwable)
Producer calls done to say that there are no more objects,
setting throwable if there was an error. |
boolean |
hasNext()
|
Object |
next()
|
void |
put(Object o)
Producer calls put to add another object (which may be
null). |
void |
remove()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private boolean waitingForProducer_
avail_
semaphore.
private boolean hasNext_
private Object next_
private Throwable throwable_
private Semaphore empty
empty
every time it produces an
object (or finishes). The consumer waits for it.
private Semaphore full
Conversely, the consumer notifies full
every time
it reads the next object. The producer waits for it, then starts
work.
Constructor Detail |
QueueIterator()
Method Detail |
public boolean hasNext()
hasNext
in interface Iterator
public Object next()
next
in interface Iterator
public void remove()
remove
in interface Iterator
private void checkError()
done(Throwable)
.
public void put(Object o)
put
to add another object (which may be
null).
public void done(Throwable throwable)
done
to say that there are no more objects,
setting throwable
if there was an error.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |