Does anyone know about the existing ruby read / write lock implementation - http://en.wikipedia.org/wiki/Readers-writer_lock ?
Preferably, this would be in a popular library or some other implementation that has been used by enough people to make it pretty bulletproof at the moment.
I do not know how much this is known, but writing them is not very difficult. Otherwise, this guy has already written one. He looks right and he has provided tests.
The link on the Jonas blog is now broken, but I created and tested another implementation, and anyone who wants to use it can:
https://github.com/alexdowad/showcase/blob/master/ruby-threads/read_write_lock.rb
In concurrent-rubygem you will find Concurrent::ReadWriteLockand Concurrent::ReentrantReadWriteLock.
concurrent-ruby
Concurrent::ReadWriteLock
Concurrent::ReentrantReadWriteLock
lock = Concurrent::ReadWriteLock.new lock.with_read_lock { data.retrieve } lock.with_write_lock { data.modify! }