seque presents a producer sequence through an asynchronously filled in-memory queue, allowing producers and consumers to run at different speeds. It returns the elements of s while buffering up to n items when consumption lags; n defaults to 100. section 9.1.4 section 9.1
The contract has two arities and several boundary conditions:
- Use (seque s) or (seque n-or-q s); s must support the sequential interface and may be empty or nil. section 9.1.4
- Pass a positive integer capacity or an ordered, finite BlockingQueue that accepts nil; LinkedBlockingQueue is the advised implementation. section 9.1.4
- Expect an empty sequence for an empty or nil s, IllegalArgumentException for zero or negative n, and NullPointerException when n is nil. section 9.1.4
Decoupling a fast producer
A slow consumer can read from a buffered producer without forcing each production step to wait: (slow-consumer (seque (fast-producer 5))) produces all five values before the consumer finishes, whereas the unbuffered form alternates production and consumption.
