summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 16:35:10 +0000
committerwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-08 16:35:10 +0000
commit13e40bdaa08d004edb45c2be872a812236296f31 (patch)
treef085e807f29f7859a588f0b5aefb061429086275 /lib
parent885527dec71812e613ecd77b2cdfb7f448b52664 (diff)
lib/monitor.rb: Backport #2240 [ruby-core:26185]; backport r25420 to ensure that the scheduled thread is alive when a monitor is released.
test/monitor/test_monitor.rb: Backport #2240 [ruby-core:26185]; added a test for the above functionality. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@28232 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)