Is there a “standard” read / write lock implementation for ruby?

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.

+3
source share
3 answers

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.

+3
source

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

+1
source

In concurrent-rubygem you will find Concurrent::ReadWriteLockand Concurrent::ReentrantReadWriteLock.

lock = Concurrent::ReadWriteLock.new
lock.with_read_lock  { data.retrieve }
lock.with_write_lock { data.modify! }
0
source

All Articles