Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
cameron314
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
4 ms
·
1.
▲
by
cameron314
12y ago
Yes, it is essentially an abstraction over a collection of SPMC queues (when using tokens to dequeue, it is actually a bit smart in that it tries to pair producers with consumers where possible). If you wrapped every enqueue operation in a
2.
▲
by
cameron314
12y ago
You're certainly right that it's not the minimum amount of complexity. But it's not that hard to implement a simple MPMC queue (e.g. if you can assume DCAS on your platform) -- what's hard is making it fast. So part of t
3.
▲
by
cameron314
12y ago
It's a matter of personal coding style preference. That's all :-) I like to document which functions I'd prefer to be inlined. It should make no difference in the output, since I believe all the methods are implicitly 'i
4.
▲
by
cameron314
12y ago
Of course it requires fences. It wouldn't be correct otherwise, and would probably not pass the tests even on x86, thanks to compiler re-ordering.
5.
▲
by
cameron314
12y ago
Yes. I hadn't looked at the disruptor pattern until yesterday, and I still don't fully understand it. I designed this queue from scratch.
6.
▲
by
cameron314
12y ago
I consider it a queue, despite its non-linearizability. I'll quote from my README where I addressed this concern: One particular consequence of this design (which seems to be non-intuitive) is that if two producers enqueue at the same
7.
▲
by
cameron314
12y ago
1. It is complicated, and, of course, with any complex code comes the possibility of bugs (especially when threads are involved!). I'd love to have a formal proof myself, but it's not a simple undertaking -- the sheer number of po
8.
▲
A Fast General-Purpose Lock-Free Queue for C++
(moodycamel.com)
59 points
by
cameron314
12y ago
|
22 comments