1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/test_mutex_m.rb
shugo 8621d0908a * lib/mutex_m.rb (sleep): added Mutex_m#sleep to support ConditionVariable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-23 07:14:54 +00:00

25 lines
489 B
Ruby

require 'test/unit'
require 'thread'
require 'mutex_m'
class TestMutexM < Test::Unit::TestCase
def test_cv_wait
o = Object.new
o.extend(Mutex_m)
c = ConditionVariable.new
t = Thread.start {
o.synchronize do
until foo = o.instance_variable_get(:@foo)
c.wait(o)
end
foo
end
}
sleep(0.0001)
o.synchronize do
o.instance_variable_set(:@foo, "abc")
end
c.signal
assert_equal "abc", t.value
end
end