Search code examples
nito.asyncex

Is Nito.AsyncEx's AsyncProducerConsumerQueue performant enough to handle gigabytes of bytes?


Is AsyncProducerConsumerQueue<byte> (maxCount: 10*1024*204) designed to handle gigabytes of bytes or is there a better way to create a streaming queue for a gigabyte of bytes? Is it better to put byte[] of some size into the queue?

It just sounds weird for me to call await Dequeue a billion times...


Solution

  • AsyncProducerConsumerQueue - like all the other types in AsyncEx - is written for maintainability and correctness, not performance.

    For a performant asynchronous queue, I recommend Channels. You do still end up calling await lots of times, but Channels use ValueTask<T> which is very performant especially in the synchronous case.