For single-producer, single-consumer should I use a BlockingCollection or a ConcurrentQueue?
- by Jonathan Allen
For single-producer, single-consumer should I use a BlockingCollection or a ConcurrentQueue?
Concerns:
* My goal is to pull up to 100 items at a time and send them as a batch to the next step.
* If I use a ConcurrentQueue, I have to manually cause it to go asleep when there is no work to be done. Otherwise I waste CPU cycles on spinning.
* If I use a BlockingQueue and I only have 99 work items, it could indefinitely block until there the 100th item arrives.
http://msdn.microsoft.com/en-us/library/system.collections.concurrent.aspx