Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote memory_order_consume to memory_order_acquire #381

Closed
wants to merge 1 commit into from

Conversation

Hincoin
Copy link
Contributor

@Hincoin Hincoin commented Mar 30, 2016

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

…ecessary synchronization guarantees. Formatting changes.
@rigtorp
Copy link

rigtorp commented Mar 31, 2016

👍 I agree, current implementation might break on non-x86_64 architectures in the future.

@ghost ghost closed this in 05cdf11 May 19, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants