From: Charles Oliver Nutter Date: 2009-01-05T20:36:04+09:00 Subject: [ruby-core:21133] Re: First whack at thread safe Containers Robert Dober wrote: > Hi all > > Charly suggested thread safe containers some weeks ago. I finally > found some time to try it, very much motivated by Jim Weirich's Ruby > Conf talk :-P. > > Please find my first implementation of a RWLock here > http://pastie.org/352321 Looks good to me at a glance, but obviously Mentalguy is probably the best one to talk to about impls like this. Are you essentially interested in porting the java.util.concurrent libraries? You could certainly choose a worse candidate for porting...I'd love to see that whole set of collections and locking primitives available in Ruby. They could probably be simplified and condensed/combined a bit too. > All comments welcome, but I am particularly interested, if monitor.rb > or sync.rb have something to offer which might outperform > ConditionVariable#wait & #signal? I'd say both are candidates for porting into native code directly (C, Java, etc). Given that people are more and more aware of how to do threaded code in Ruby, and given that these libraries are often going to be key to that effort, they really ought to be as screaming fast as possible. The current implementations are probably not slow, but definitely could be sped up if they were pure native. Note that in all recent versions of 1.8, 1.9, and JRuby, the old "thread.rb" library has been replaced with Mentalguy's fastthread library, so at least those items should be solid and speedy already. - Charlie