You have a 3 stage pipeline
run -- (inputQueue) -- worker -- (outputQueue) -- consumer
all 3 stages run at the same time so as soon as 1 item is in inputQueue
it can be immediately taken out and moved to outputQueue
, as soon as one item is put in to outputQueue
it can be immediately taken out and processed.
So to get a count of 100 you would need to do
(100 - number of items "run" has put in to "inputQueue") + "inputQueue.Count" + some number between 0 and "threadCount" representing items that have been taken out of "inputQueue" but have not yet been put in "outputQueue" + "outputQueue.Count" + the number of items "consumer" has taken out of "outputQueue"
Beacuse your number of threads and waits are perfectly balanced for the load it is most likely the above fomula would be 0 + 0 + 4 + 0 + 96
with the last 4 elements waiting to be processed in worker
with everything else already processed by consumer
. If you did half the worker threads and made consumer take 4 times longer to process you would have numbers like 0 + 48 + 2 + 25 + 25
with 48 waiting to be processed by a worker, 2 being processed by a worker, 25 waiting to be processed by consumer, and 25 already processed by consumer.