我需要环形缓冲区的类似流的实现,最好是线程安全的,但是我可以解决该问题。我将不胜感激对现有实现的任何引用或对如何正确进行此操作的想法。
I'm thinking MemoryStream
, but something that gives up memory from anything that's read the same way that a queue would. A really silly version would just use a ConcurrentQueue<byte>
, but I'd like my app to finish sometime before the heat death of the universe and not drive the garbage collector insane.
而且,由于有人认为这值得一谈,所以让我更清楚地表达这个问题:
如何使用一个线程安全的,动态大小的内部缓冲区实现流类而又不会产生过多的分配?