Fix missing "last-minute-reprieve" load-acquire in Baton and SaturatingSemaphore
Summary: [Folly] Fix missing "last-minute-reprieve" load-acquire in `Baton` and `SaturatingSemaphore`. If the CAS fails, it is because `post` with its store-release was invoked just after spinning but just before parking the thread. So the failure load needs a matching load-acquire. We cannot actually move the load-acquire into the CAS until C++17, since the failure memory order must be not stronger than the success memory order until C++17. Therefore, simulate the effect with an acquire fence in the CAS failure case. The CAS success case does not need a load-acquire; there is already a load-acquire after the thread is unparked. Reviewed By: davidtgoldblatt Differential Revision: D6851304 fbshipit-source-id: a43243ad6a35bd9a53a9d2a5958b50a6c8806419
Showing
Please register or sign in to comment