Promote memory_order_consume to memory_order_acquire
Summary: The current use case of `std::memory_order_consume` in this project was intended to provide the appropriate synchronization in cases where a consumer spins on `while( spsc_queue.empty() ) {} `, and then attempts to use an element of the queue since the loop was broken out of, according to comments [here](https://reviews.facebook.net/D48141). Consume semantics do not provide this guarantee according to the standard since there is no data dependency from the producer that can be carried to the consumer by doing a load-consume from the corresponding functions. What is needed is a load-acquire. Current compilers promote `memory_order_consume` to `memory_order_acquire`. Thus, this example appears to work simply due to the promotion from consume to acquire, but would fail to generate the right synchronization instructions on weaker architectures once `memory_order_consume` is implemented as intended. Therefore, the `memory_order` should be tightened to `memory_order_acquire` to guarantee visibility to the consumer Closes https://github.com/facebook/folly/pull/381 Reviewed By: djwatson Differential Revision: D3173574 Pulled By: nbronson fbshipit-source-id: b109be2e74f016750a3fe1f848e3fc66e609b9d2
Showing
Please register or sign in to comment