From: "Guy N. Hurst" Date: 2002-03-13T14:04:43+09:00 Subject: Re: Some potential RCRs > Bob Alexander wrote: ... > The built-in Mutex object should be nestable. > > Acquiring a mutex in nested contexts in the same thread should not cause > deadlock. It doesn't seem appropriate for a language at Ruby's level to have a > non-nestable Mutex, and it is a pothole for program errors. > > "Yukihiro Matsumoto" wrote ... > > I will take time to investigate it later (I'm not a thread expert). > > Maybe one of you help me with better implementation. > Sean O'Dell wrote: ... > I think this definitely needs to change, if that's how it works, or at least > it should be an option when creating the mutex. The same context should be > able to call the same mutex recursively and obtain the lock each time. Each > time increasing the mutex' lock count, each release decrementing the mutex > lock count. > > Often, multiple routines called in the same context will need to lock the > same mutex to ensure a resource is safely locked. Since the same context > isn't likely to step on itself because of a multithreading issue > See http://www.lepton.fr/ruby/rmutex/ Or, you can use a monitor. (See monitor.rb) Guy N. Hurst