"Lloyd Zusman" <ljz / asfast.com> schrieb im Newsbeitrag news:zn5dbwke.fsf / asfast.com... > "Robert Klemme" <bob.news / gmx.net> writes: > > > "Lloyd Zusman" <ljz / asfast.com> schrieb im Newsbeitrag > > news:m3vfg2tsvl.fsf / asfast.com... > >> > >> [ ... ] > >> > >> Sync_m has been around ever since 1.6.x, and it's excplicitly mentioned > >> in the Pickaxe book (on page 120, the last line of the "Condition > >> Variables" section of Chapter 11, "Threads and Processes"). You can see > >> the code in RUBYINSTALLDIR/lib/sync.rb > > > > Oh, once again learned something new. But as far as I can see it's only > > mentioned at this single location - no examples no additional > > explanations. > > Yes, sync.rb (containing Sync_m and Synchronizer_m) is not mentioned or > documented anywhere else that I can find. I'm not sure where I stumbled > upon it ... I probably saw it used in someone else's code and then > investigated it. Although the mutex and monitor classes also can work > here, I prefer Sync_m in this case because its name reflects the exact > use to which I am putting it: synchronization. Monitor and Mutex are also fixed terms in the MT community. It looks, like everyone put his term in here. :-) As far as I remember the difference between Monitor and Mutex is that Monitor is reentrant while Mutex is not. As far as I can see Sync and Sync_m are reentrant, too: require 'thread' require 'monitor' require 'sync' [Monitor, Sync, Mutex].each do |cl| x = cl.new puts "outside"; p x begin x.synchronize { puts "first"; p x; x.synchronize { puts "nest"; p x } } rescue Exception => e puts e end end > Adding a number of small methods would decrease maintainability of my > particular program, IMO. That is not true in general, and I indeed do > this on other kinds of projects. However, think that it does apply in > this case. > > But there is plenty of room to differ here. Yeah, often these things are at least partly a matter of taste and individual habit. :-) > I refactored the code even more, based on our discussions and some ideas > of my own. If you're interested, I can privately email you the latest > version. [x] interested [ ] not interested Cheers robert