mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
4b298ad77a
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
27 lines
568 B
Ruby
27 lines
568 B
Ruby
# frozen_string_literal: false
|
|
require 'test/unit'
|
|
require 'thread'
|
|
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
|