Provide a read-write lock
alexdowad opened this issue · 2 comments
Just discovered this project; it looks like you guys have put together a very nice suite of utilities.
It looks like you don't have a read-write lock yet (one which allows multiple concurrent readers, but only one concurrent writing). A couple years ago, I needed one for a Ruby project and couldn't find anything good, so I developed my own implementation. Here it is: https://github.com/alexdowad/showcase/blob/master/ruby-threads/read_write_lock.rb
I put a fair amount of time into testing and verifying this implementation, and also had a couple of other Ruby developers do code review and test it on their machines as well. It has worked in production for me, without any problems detected. So while more review would be good, it is already somewhat mature.
A RW lock which "spins" when the lock is taken would be lighter (less memory footprint per lock), but is more "dangerous" -- the user needs to know what they are doing when they select such a lock.
If you would like to use this RW lock, please take it and distribute it under your existing license conditions. Of course, I may also use it in other places and distribute it under other licenses.
@alexdowad Thank you for your kind words, and for the offer of your code. I think a read-write lock would be an excellent addition to our toolset. And @chrisseaton will be especially pleased that you included benchmark tests (he's a staunch advocate of performance testing). Would you like to submit this as a PR so that your name gets in the commit log?
Dear @jdantonio, when I have some time I'll get the code in shape for you
to merge it smoothly and submit a PR.
On Sat, Aug 9, 2014 at 5:34 PM, jdantonio notifications@github.com wrote:
@alexdowad https://github.com/alexdowad Thank you for your kind words,
and for the offer of your code. I think a read-write lock would be an
excellent addition to our toolset. And @chrisseaton
https://github.com/chrisseaton will be especially pleased that you
included benchmark tests (he's a staunch advocate of performance testing).
Would you like to submit this as a PR so that your name gets in the commit
log?—
Reply to this email directly or view it on GitHub
#146 (comment)
.