mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
6064132c42
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
26 lines
551 B
Ruby
26 lines
551 B
Ruby
# frozen_string_literal: false
|
|
require 'test/unit'
|
|
require 'mutex_m'
|
|
|
|
class TestMutexM < Test::Unit::TestCase
|
|
def test_cv_wait
|
|
o = Object.new
|
|
o.instance_variable_set(:@foo, nil)
|
|
o.extend(Mutex_m)
|
|
c = Thread::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
|