{"action":"created","issue":{"url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/424","labels_url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/424/labels{/name}","comments_url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/424/comments","events_url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/424/events","html_url":"https://github.com/ruby-concurrency/concurrent-ruby/pull/424","id":108244441,"number":424,"title":"move attr_volatile into Concurrent::Synchronization::Volatile module","user":{"login":"colinsurprenant","id":2010,"avatar_url":"https://avatars.githubusercontent.com/u/2010?v=3","gravatar_id":"","url":"https://api.github.com/users/colinsurprenant","html_url":"https://github.com/colinsurprenant","followers_url":"https://api.github.com/users/colinsurprenant/followers","following_url":"https://api.github.com/users/colinsurprenant/following{/other_user}","gists_url":"https://api.github.com/users/colinsurprenant/gists{/gist_id}","starred_url":"https://api.github.com/users/colinsurprenant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinsurprenant/subscriptions","organizations_url":"https://api.github.com/users/colinsurprenant/orgs","repos_url":"https://api.github.com/users/colinsurprenant/repos","events_url":"https://api.github.com/users/colinsurprenant/events{/privacy}","received_events_url":"https://api.github.com/users/colinsurprenant/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-25T01:18:28Z","updated_at":"2015-09-28T13:32:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/pulls/424","html_url":"https://github.com/ruby-concurrency/concurrent-ruby/pull/424","diff_url":"https://github.com/ruby-concurrency/concurrent-ruby/pull/424.diff","patch_url":"https://github.com/ruby-concurrency/concurrent-ruby/pull/424.patch"},"body":"add a new `Concurrent::Synchronization::Volatile` module which can be included into any class to add the `attr_volatile` class method. \r\n\r\nExample:\r\n```ruby\r\nclass Foo\r\n  include Concurrent::Synchronization::Volatile\r\n\r\n  attr_volatile :bar\r\n\r\n  def initialize\r\n    self.bar = 1\r\n  end\r\nend\r\n\r\nfoo = Foo.new\r\nfoo.bar\r\n=> 1\r\nfoo.bar = 2\r\n=> 2\r\n```\r\n\r\nFor this the respective `{jruby|mri|rbx}_object.rb` have been refactored into modules but the original classes were preserved and uses the new modules so not to break backward compatibility.\r\n\r\nThe Java JRuby synchronization library has been refactored to also add the previous `JRubyObject` method in the new `JRubyAttrVolatile ` module. \r\n\r\nI believe the only risk with the Java synchronization library changes is related to having the volatile  `threadContext` field used as a memory barrier to now be located at the module level and thus will be shared across the including objects using the module. I believe the `happens-before` / memory barrier is preserved but may be less efficient than having per-object volatile field as memory barrier. \r\n\r\nI only tested on JRuby 1.7.22 and all specs are passing.\r\n\r\n- [x] add specific specs for the module inclusion\r\n- [x] mri build and run specs\r\n- [ ] rbx build and run specs"},"comment":{"url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/comments/143744670","html_url":"https://github.com/ruby-concurrency/concurrent-ruby/pull/424#issuecomment-143744670","issue_url":"https://api.github.com/repos/ruby-concurrency/concurrent-ruby/issues/424","id":143744670,"user":{"login":"jdantonio","id":173910,"avatar_url":"https://avatars.githubusercontent.com/u/173910?v=3","gravatar_id":"","url":"https://api.github.com/users/jdantonio","html_url":"https://github.com/jdantonio","followers_url":"https://api.github.com/users/jdantonio/followers","following_url":"https://api.github.com/users/jdantonio/following{/other_user}","gists_url":"https://api.github.com/users/jdantonio/gists{/gist_id}","starred_url":"https://api.github.com/users/jdantonio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdantonio/subscriptions","organizations_url":"https://api.github.com/users/jdantonio/orgs","repos_url":"https://api.github.com/users/jdantonio/repos","events_url":"https://api.github.com/users/jdantonio/events{/privacy}","received_events_url":"https://api.github.com/users/jdantonio/received_events","type":"User","site_admin":false},"created_at":"2015-09-28T13:32:34Z","updated_at":"2015-09-28T13:32:34Z","body":"The tests that failed on the lat Travis build can be ignored with respect to this PR. Those are mine. I've been trying to clean up our tests by removing sleep statements, make them more deterministic, etc. I made changes on master that caused those failures. I believe I have them fixed on the latest master. If they continue to be a problem I'll fix them."}}