From: Paul Brannan Date: 2004-08-28T13:06:31+09:00 Subject: Re: Request For Comments: exception safe ConditionVariable#wait On Sat, Aug 28, 2004 at 06:08:39AM +0900, Bill Kelly wrote: > I'm sorry, I'm not sure I'm following. Does the nested > timeout here violate any safeguards inside the revised > ConditionVariable#wait implementation? I realize the > rescue Timeout::Error there is not sufficient to > squelch timeout exceptions from any nested/outer timeout > block. Your outer timeout would need to rescue its own > exceptions as well. . . . Is that what you were referring > to? Or am I not understanding your example? Your revised ConditionVariable#wait: def wait(mutex) unlocked = false begin mutex.exclusive_unlock do unlocked = true @waiters.push(Thread.current) Thread.stop end rescue # Timeout::Error @waiters.delete Thread.current # Q: is Array#delete an atomic operation? raise ensure mutex.lock if unlocked end end What happens if you get a timeout first inside the exclusive_unlock block, then inside the rescue (before the delete occurs)? (I believe that this is a pretty rare race condition, but is still possible). Paul