- The producer is finite, as should be the consumer.
- The problem is when to stop, not how to run.
- Communication can happen over any type of BlockingQueue.
- Can't rely on poisoning the queue(PriorityBlockingQueue)
- Can't rely on locking the queue(SynchronousQueue)
- Can't rely on offer/poll exclusively(SynchronousQueue)
- Probably even more exotic queues in existence.
Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer.
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/seque
My attempts so far + some tests: https://gist.github.com/934781
Solutions in Java or Clojure appreciated.