Thanks so much!
Actually, this is pretty much *exactly* what I
ended up doing, and so far it's working like a
charm. Thanks for the heads up, it looks like
great minds just might think alike :)
Steve
At 02:09 AM 5/9/2008, you wrote:
Hi Steve,
When the stack is empty, I don't want to end the run. The stack
may fill again in the future! OK, so I can set 'hasNext' to always
return true easily enough. But when calling 'getNext', what should
I set the jCas to so the pipeline safely 'no-ops?' Is there a way
to do this?
Imagine if you always return true from hasNext() and then return some
no-op in getNext(). Your programm would be stuck in an endless loop
(until documents become available) and produce heat by keeping the
CPU busy. If you want to process documents as they become available I
would advise you to deploy UIMA in a separate thread. The document
reader should then poll a document queue you would need to set up.
Your main thread put()s documents into the queue, the reader in the
UIMA thread take()s them from there. The queue should be implemented
so that a take() call blocks until data becomes available. That way
your reader can
simply call take() on the queue and will be sleeping until data
becomes available in the queue.
One of the implementations of the BlockingQueue interface from Java
1.5 should work fine for you.
An example is provided there.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/
BlockingQueue.html
Richard Eckart
Technische Universität Darmstadt
Institute of Linguistics and Literary Studies
Department of English Linguistics
Hochschulstrasse 1
64289 Darmstadt
Germany