Circular lock-free buffer

后端 未结 18 733
悲哀的现实
悲哀的现实 2020-11-29 15:00

I\'m in the process of designing a system which connects to one or more stream of data feeds and do some analysis on the data than trigger events based on the result. In a t

18条回答
  •  醉酒成梦
    2020-11-29 15:58

    Sometime ago, I've found a nice solution to this problem. I believe that it the smallest found so far.

    The repository has a example of how use it to create N threads (readers and writers) and make then share a single seat.

    I made some benchmarks, on the test example and got the following results (in million ops/sec) :

    By buffer size

    By number of threads

    Notice how the number of threads do not change the throughput.

    I think this is the ultimate solution to this problem. It works and is incredible fast and simple. Even with hundreds of threads and a queue of a single position. It can be used as a pipeline beween threads, allocating space inside the queue.

    The repository has some early versions written in C# and pascal. Im working to make something more complete polished to show its real powers.

    I hope some of you can validate the work or help with some ideas. Or at least, can you break it?

提交回复
热议问题