sonic-pi
https://github.com/sonic-pi-net/sonic-pi
C++
Code. Music. Live.
ThreadSafe::AtomicReferenceCacheBackend::Node#try_await_lock
Spins a while if +LOCKED+ bit set and this node is the first of its bin, and then sets +WAITING+ bits on hash field and blocks (once) if they are still set. It is OK for this method to return even if lock is not available upon exit, which enables these simple single-wait mechanics. The corresponding signalling operation is performed within callers: Upon detecting that +WAITING+ has been set when unlocking lock (via a failed CAS from non-waiting +LOCKED+ state), unlockers acquire the +cheap_synchronize+ lock and perform a +cheap_broadcast+.
Edit
git clone [email protected]:sonic-pi-net/sonic-pi.git
cd sonic-pi
open app/server/ruby/vendor/thread_safe/lib/thread_safe/atomic_reference_cache_backend.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ThreadSafe--AtomicReferenceCacheBackend--Node-try_await_lock-for-pr
# Commit to gitgit add app/server/ruby/vendor/thread_safe/lib/thread_safe/atomic_reference_cache_backend.rbgit commit -m "better docs for ThreadSafe::AtomicReferenceCacheBackend::Node#try_await_lock"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ThreadSafe--AtomicReferenceCacheBackend--Node-try_await_lock-for-pr
hub pull-request
# Celebrate!