summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-25 07:45:29 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-25 07:45:29 +0000
commitc3d27c35fef49e70603fdf532fee51d1cd75f650 (patch)
tree21f768fd6d6ce3b6f851ecd6e5ef1b98d90e08a3 /lib
parent61087d93c539244760395ac263528c6ae5cacb27 (diff)
merge revision(s) 25420:
* lib/monitor.rb (MonitorMixin.mon_release): ensure the scheduled thread to be alive when a thread is releasing a monitor. #2240 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@25916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/monitor.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 4c146c8086..9158f9fb32 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -288,11 +288,15 @@ module MonitorMixin
@mon_owner = Thread.current
end
+ # mon_release requires Thread.critical == true
def mon_release
@mon_owner = nil
- t = @mon_waiting_queue.shift
- t = @mon_entering_queue.shift unless t
- t.wakeup if t
+ while t = @mon_waiting_queue.shift || @mon_entering_queue.shift
+ if t.alive?
+ t.wakeup
+ return
+ end
+ end
end
def mon_enter_for_cond(count)