Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Lock-Free Data Structures. The Evolution of a Stack (kukuruku.co)
38 points by skazka16 on Feb 24, 2015 | hide | past | favorite | 2 comments


Elimination 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 [2] https://github.com/ben-manes/caffeine


> 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: