Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Volatile semantics for #get, #set, and #swap #4

Merged
merged 5 commits into from
Nov 15, 2014
Merged

Volatile semantics for #get, #set, and #swap #4

merged 5 commits into from
Nov 15, 2014

Conversation

alexdowad
Copy link
Contributor

In Java, reads/writes to volatile variables provide definite, clearly-defined guarantees for memory visibility and "happens-before" relationships. Ruby (sadly) doesn't specify what memory-model semantics reads and writes to variables have. Basically, it does whatever the underlying compiler and hardware do "by default".

The atomic gem has a great opportunity to make things right. These patches give Atomic#get, #set, and #swap semantics like those of a Java volatile. Actually, they may be stronger -- I'd like to just use a load barrier in ir_get and a store barrier in ir_set, but I don't know how to do that short of using inline assembly.

Feedback please!

Closes #3.

@alexdowad alexdowad changed the title Volatile semantics for get set Volatile semantics for #get, #set, and #swap Aug 9, 2014
@jdantonio
Copy link
Member

@alexdowad Thank you for this update. Would you mind submitting this PR to the concurrent-ruby repo, too? This gem has been merged into concurrent-ruby, and @headius has indicated he will end-of-life ruby-atomic. We'll need to make this change in the other gem.

@alexdowad
Copy link
Contributor Author

@jdantonio, so in the future, the atomic gem will be no more? We will all have to start using concurrent-ruby?

@jdantonio
Copy link
Member

That is what @headius had previously indicated. He originally offered to merge both ruby-atomic and thread_safe into concurrent-ruby in May of this year during this discussion. In the ensuing discussion he stated that he wanted to do one more release of ruby-atomic that defers to concurrent-ruby. We've done the initial merge of ruby-atomic and have released several RC builds of concurrent-ruby with the merged code. We are on track for a full release later this week.

As far as I know @headius still plans to end-of-life ruby-atomic once we release concurrent-ruby 0.7.0, but that is entirely his decision. He and I will both be attending the Steel City Ruby conference next weekend. I expect we will talk more then.

jdantonio added a commit that referenced this pull request Nov 15, 2014
Volatile semantics for #get, #set, and #swap
@jdantonio jdantonio merged commit 9e720c8 into ruby-concurrency:master Nov 15, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Unconditional set" operation which provides happens-before and memory-visibility guarantees needed
2 participants