|
|
|
|
|
by nly
19 days ago
|
|
What's important is you know the trade-offs you are making. You can't have a bounded queue that is always non-blocking because slow consumers can block producers. You can't have a global FIFO order + multiple producers without slow producers blocking consumers. You can't have a global FIFO order + have have non-atomic reserve and commit without a interrupted/de-scheduled producer thread being able to block the consumer If you want atomic commit then you lose separate reserve which means either unbounded memory or atomic fixed-size data with sentinel values, ABA problems etc. There are trade-offs everywhere, and it's best to pick the data structure that fits your needs just like any other problem. |
|
That part I think is most crucial. Neither "Lock-free" nor "Wait-free" are vague terms for how awesome a thing is, they're specific properties which are expensive to provide, if you need such a property it was indispensable, if you don't need it then you can likely do better without it.