|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.util.ThreadInterface
simple Interface following the multithreaded producer-consumer paradigm. Producer sends objects to consumer. Objects are stored if producer is faster than consumer.
Nested Class Summary | |
(package private) class |
ThreadInterface.ChainElem
simple subclass: element of a simple linked list. |
Field Summary | |
(package private) boolean |
closing
|
(package private) boolean |
consumersleeping
|
(package private) ThreadInterface.ChainElem |
first
|
(package private) ThreadInterface.ChainElem |
worked
|
Constructor Summary | |
ThreadInterface()
simple constructor: internal chain is initialized. |
Method Summary | |
void |
close()
closes interface. |
java.lang.Object |
consume()
Called by consumer: delivers next (produced) object. |
java.lang.Object |
consume(long waittime)
Called by consumer: delivers next (produced) object but waits no longer than waittime milliseconds. |
boolean |
consumerSleeping()
returns true if consumer is sleeping. |
boolean |
consumerWouldIdle()
returns true if no input for consumer is there. |
boolean |
isClosing()
Returns whether the ThreadInterface is just about closing. |
void |
produce(java.lang.Object o)
called by producer: puts a new object into the internal chain and notify()s the consumer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
ThreadInterface.ChainElem first
ThreadInterface.ChainElem worked
boolean consumersleeping
boolean closing
Constructor Detail |
public ThreadInterface()
Method Detail |
public void close()
public boolean isClosing()
public java.lang.Object consume() throws java.io.IOException
java.io.IOException
- If the ThreadInterface is closed in the meantime.public java.lang.Object consume(long waittime) throws java.io.IOException
If waittime is null, consume() will never return null (as long as it has not been produced). Instead, it will wait infinitely. If consume() is called on a closed ThreadInterface and nothing is left in the queue, an IOException is thrown. This is also the case if the ThreadInterface is closed while consume() is wait()ing and nothing has been added to the queue in advance.
waittime
- Milliseconds to wait for new stuff longest. Zero for "infinite".
java.io.IOException
- If ThreadInterface is closed while waiting.public boolean consumerSleeping()
public void produce(java.lang.Object o) throws java.io.IOException
java.io.IOException
public boolean consumerWouldIdle()
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |