3 ms·
Lock-Free Data Structures. The Evolution of a Stack
- NovaX 12y agoElimination can be enhanced by using a combination strategy, such as DECS [1]. Using a combiner approach should also work on a queue structure, though interestingly enough there is a paper on elimination-based fifo queues. I wrote an elimination stack in Java [2], but I haven't gotten around to adding combining to the arena yet. The performance is pretty good compared to other shared concurrent structures. [1] http://www.cs.bgu.ac.il/~hendlerd/papers/DECS.pdf http://www.cs.bgu.ac.il/~hendlerd/papers/DECS.pdf [2] https://github.com/ben-manes/caffeine https://github.com/ben-manes/caffeine
- zamalek 12y ago> back-off Another solution is to simply return false and leave the decision of what to do, to the caller. Effectively: bool try_push(value_type& value); bool try_pop(value_type* result); Most callers will simply: while(!try_push(&val)) bkoff(); However, in my specific case I was writing a toy thread pool. This meant that a failed pend could just result in an attempt to pend it to a different worker thread, instead of trying the same stack over again.