sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
ThreadSafe::Util::Volatile#attr_volatile
Provides +volatile+ (in the JVM's sense) attribute accessors implemented atop of the +AtomicReference+s.
Usage:
class Foo
extend ThreadSafe::Util::Volatile
attr_volatile :foo, :bar
def initialize(bar)
super() # must super() into parent initializers before using the volatile attribute accessors
self.bar = bar
end
def hello
my_foo = foo # volatile read
self.foo = 1 # volatile write
cas_foo(1, 2) # => true | a strong CAS
end
endEdit
git clone [email protected]:sonic-pi-net/sonic-pi.git
cd sonic-pi
open app/server/ruby/vendor/thread_safe/lib/thread_safe/util/volatile.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ThreadSafe--Util--Volatile-attr_volatile-for-pr
# Commit to gitgit add app/server/ruby/vendor/thread_safe/lib/thread_safe/util/volatile.rbgit commit -m "better docs for ThreadSafe::Util::Volatile#attr_volatile"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ThreadSafe--Util--Volatile-attr_volatile-for-pr
hub pull-request
# Celebrate!