Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait-free queue implementation in C++

Is it possible to implement a Concurrent Queue which is completely wait-free and can support simultaneously multiple writers and readers?I know I can use mutexes or an existing library, but I really want to implement it myself.Any ideas?

like image 735
ulak blade Avatar asked Jan 13 '23 22:01

ulak blade


1 Answers

You can find a wait-free queue for multiple enqueuers and dequeuers here, but as @David Schwartz said this will not be necessarily faster just for being wait-free. This is another paper about wait-free queue. On the references of these papers you also can find other proposed queues based on arrays, that means they have a limited capacity, but they are faster than those based on lists.

If you are looking for a practical solution Michael and Scott's Lock-Free queue is probably a good alternative.

If you want to learn more and give it a try yourself, Here you can find a good resume of the possible alternatives and there are a few code examples.

like image 53
ees_cu Avatar answered Jan 22 '23 11:01

ees_cu