.NET 中现有的环形缓冲区是否可以有多个使用者?
想知道 .NET 中是否存在现有的环形缓冲区,它只有一个写入器,但可以有多个使用者?
不用说,有多个线程从该缓冲区读取(但只有一个线程写入),因此实现必须是线程安全的。
Wondering if there is an existing ring buffer in .NET that has only one writer, but can have multiple consumers?
Needless to say, there are multiple threads reading from this buffer (but only one thread writing), so the implementation would have to be thread safe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这篇文章,它真的很好 http://www.albahari.com/threading/part5.aspx 我建议你想要
BlockingCollection
look at this article its really quite good http://www.albahari.com/threading/part5.aspx I would suggest you want the
BlockingCollection<T>
看一下
ConcurrentQueue
和 类似 - 这些是线程安全的并且非常快,因为大多数事情都已实现无锁...它们可以处理多个消费者,甚至多个编写者...有关很好的教程等,请参阅http://geekswithblogs.net/BlackRabbitCoder/archive/2011/02/10/c.net-little-wonders-the-concurrent-collections-1-of-3.aspx
Take a look at
ConcurrentQueue
and similar - these are thread-safe and very fast since most things are implemented lock-free... they can handle multiple consumers and even multiple writers...For a nice tutorial etc. see http://geekswithblogs.net/BlackRabbitCoder/archive/2011/02/10/c.net-little-wonders-the-concurrent-collections-1-of-3.aspx
每当 .NET 中的缓冲 + 线程时,您都需要 Rx。请参阅
new ReplayBuffer(int)
。 http://msdn.microsoft.com/en-us/library/hh229429.aspx最后我听说 Disruptor.NET 有很多复杂的细节,在获得任何性能优势之前,您需要了解这些细节。我建议首先在 Rx 中建模,当您在 Rx 中使用小型(<10k)数据集时,转向 Disruptor,然后关注性能。
Whenever buffering + threading in .NET you want Rx. See
new ReplayBuffer<T>(int)
. http://msdn.microsoft.com/en-us/library/hh229429.aspxLast I heard Disruptor.NET has a lot of intricate details you need to understand before you get any performance benefits. I would suggest modelling in Rx first and moving to Disruptor when you have small (<10k) data sets working in Rx, then focus on performance.