1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
wyhaines 2010-06-08 16:35:10 +00:00
parent 885527dec7
commit 13e40bdaa0
4 changed files with 50 additions and 10 deletions

View file

@ -1,8 +1,14 @@
Wed June 9 01:05:00 Kirk Haines <khaines@ruby-lang.org>
* 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.
Tue Jun 8 23:45:00 2010 Kirk Haines <khaines@ruby-lang.org>
* regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching.
* test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6.
* ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th!
* regexp.c: Backport #3403; backported from r28192 to fix a bug with non-greedy matching. r28231
* test/ruby/test_regexp.rb: Backport #3403; added this test suite, commenting out inapplicable tests to the current 1.8.6. r28231
* ChangeLog: Got my date wrong in the last few entries. Tuesday is the 8th, not the 9th! r28231
Tue Jun 8 20:40:00 2010 Kirk Haines <khaines@ruby-lang.org>

View file

@ -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)

View file

@ -54,6 +54,32 @@ class TestMonitor < Test::Unit::TestCase
assert_equal((1..10).to_a, ary)
end
def test_killed_thread_in_synchronize
ary = []
queue = Queue.new
t1 = Thread.start {
queue.pop
@monitor.synchronize {
ary << :t1
}
}
t2 = Thread.start {
queue.pop
@monitor.synchronize {
ary << :t2
}
}
@monitor.synchronize do
queue.enq(nil)
queue.enq(nil)
assert_equal([], ary)
t1.kill
t2.kill
ary << :main
end
assert_equal([:main], ary)
end
def test_try_enter
queue1 = Queue.new
queue2 = Queue.new
@ -94,6 +120,10 @@ class TestMonitor < Test::Unit::TestCase
assert_equal(true, result1)
assert_equal("bar", a)
end
end
def test_timedwait
cond = @monitor.new_cond
b = "foo"
queue2 = Queue.new

View file

@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.6"
#define RUBY_RELEASE_DATE "2010-06-08"
#define RUBY_RELEASE_DATE "2010-06-09"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20100608
#define RUBY_PATCHLEVEL 407
#define RUBY_RELEASE_CODE 20100609
#define RUBY_PATCHLEVEL 408
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 6
#define RUBY_RELEASE_YEAR 2010
#define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 8
#define RUBY_RELEASE_DAY 9
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];