News for hackers. Stuff that matters.
Re:Show HN: Evenk C++ concurrency library by avdicius on Friday April 24, 2015 @11:29AM (#9434000)
Thank you very much for your review.

- I have a TATAS lock implementation elsewhere: https://github.com/ademakov/MainMemory/blob/master/src/base/...

Could add it to Evenk as well.

- Exchanged value in FutexLock is not discarded, it is used in the conditions of the `if` and `while` statements. In both cases the returned value of 0 means that we've got the lock and the next thing executed will be the `break` statement. If either value of 1 or 2 is returned then we need to proceed with spinning. The `if` condition relies on short-circuiting of || operator, so the exchange is only done if the `value` variable is equal to 1. If it were equal to 0 then the CAS in the for loop would have returned true leading to an early exit.

The idea of using backoff before futex is picked from this article: http://locklessinc.com/articles/mutex_cv_futex/

The author suggests to spin a little in unlock as well, but I didn't go that far.

There are no comments on this comment yet.