mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@d419e74
This commit is contained in:
parent
26a9f80c82
commit
a2fac1d72c
44 changed files with 772 additions and 514 deletions
|
@ -32,6 +32,50 @@ describe "ConditionVariable#wait" do
|
|||
th.join
|
||||
end
|
||||
|
||||
it "can be interrupted by Thread#run" do
|
||||
m = Mutex.new
|
||||
cv = ConditionVariable.new
|
||||
in_synchronize = false
|
||||
|
||||
th = Thread.new do
|
||||
m.synchronize do
|
||||
in_synchronize = true
|
||||
cv.wait(m)
|
||||
end
|
||||
:success
|
||||
end
|
||||
|
||||
# wait for m to acquire the mutex
|
||||
Thread.pass until in_synchronize
|
||||
# wait until th is sleeping (ie waiting)
|
||||
Thread.pass while th.status and th.status != "sleep"
|
||||
|
||||
th.run
|
||||
th.value.should == :success
|
||||
end
|
||||
|
||||
it "can be interrupted by Thread#wakeup" do
|
||||
m = Mutex.new
|
||||
cv = ConditionVariable.new
|
||||
in_synchronize = false
|
||||
|
||||
th = Thread.new do
|
||||
m.synchronize do
|
||||
in_synchronize = true
|
||||
cv.wait(m)
|
||||
end
|
||||
:success
|
||||
end
|
||||
|
||||
# wait for m to acquire the mutex
|
||||
Thread.pass until in_synchronize
|
||||
# wait until th is sleeping (ie waiting)
|
||||
Thread.pass while th.status and th.status != "sleep"
|
||||
|
||||
th.wakeup
|
||||
th.value.should == :success
|
||||
end
|
||||
|
||||
it "reacquires the lock even if the thread is killed" do
|
||||
m = Mutex.new
|
||||
cv = ConditionVariable.new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue