From: Ilmari Heikkinen Date: 2005-12-12T19:32:42+09:00 Subject: Re: Ruby for small devices ? On 12/9/05, Wilson Bilkovich wrote:> Check out the "Embedding Ruby" presentation from RubyConf 2005:> http://www.zenspider.com/dl/rubyconf2005/EmbeddedRuby.pdf The leaking Mutex problem showcased in the presentation page 27, Ithink the following change fixes it at least for #synchronize : def unlock return unless @locked Thread.critical = true- @locked = false begin t = @waiting.shift+ @locked = t # if there is a waiting thread, keep the mutex locked t.wakeup if t rescue ThreadError retry end Thread.critical = false# if @locked is false, a thread entering #lock sets Thread.critical=true here,# checks for @locked, sees that it's false, and jumps the queue begin t.run if t rescue ThreadError end self end