This will abort both the producer and consumer possibly removing items from the queue to make room for our END_OF_QUEUE marker.
Wait for both the producer and consumer threads (if any) to finish
Wait for the consumer thread (if any) to finish
Wait for the producer thread (if any) to finish
Note: It's not clear what the correct behavior of this method is.
Note: It's not clear what the correct behavior of this method is. It will currently block until the producer/consumer threads have cleanly finished.
Run the function in a separate producer thread.
Run the function in a separate producer thread. Should only be called once since it will close the Builder when the thread finishes.
(Since version ) see corresponding Javadoc for more information.
A LazySeq producer/consumer pair that uses a BlockingQueue
I think this is Thread-Safe
2021-02-19 - This was updated to allow passing in an arbitrary BlockingQueue implementation (e.g. an LMDBBlockingDeque for using an off-heap disk-backed queue). I removed the END_OF_QUEUE marker so that the BlockingQueue could be typed as a BlockingQueue[A] instead of an BlockingQueue[AnyRef] to make serialization in LMDBBlockingDeque work better.
It looks like there is a lot of cleanup potential in this class. After some original threading problems around handling exceptions in the Producer and Consumer threads it looks like I went a little overboard on error handling. There is probably room for a lot of simplification.