Commit 2a32c935 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Use relaxed CAS in Baton wait path

Summary:
[Folly] Use relaxed CAS in `Baton` wait path.

As is done in `SaturatingSemaphore`. There are surrounding operations on `state_` with stronger memory orders.

Reviewed By: nbronson

Differential Revision: D6726704

fbshipit-source-id: 8032db4b98a09455c84c730e2e99515d1a9442da
parent f1f9cb87
......@@ -318,7 +318,11 @@ class Baton {
// guess we have to block :(
uint32_t expected = INIT;
if (!state_.compare_exchange_strong(expected, WAITING)) {
if (!state_.compare_exchange_strong(
expected,
WAITING,
std::memory_order_relaxed,
std::memory_order_relaxed)) {
// CAS failed, last minute reprieve
assert(expected == EARLY_DELIVERY);
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment