Disable test on 1.8.7, since workaround is to allow blocking on that version
This commit is contained in:
parent
d2f8af03eb
commit
90a9f37da4
|
@ -158,35 +158,37 @@ module ProcessShared
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows other threads in a process to continue while waiting' do
|
unless RUBY_VERSION == '1.8.7'
|
||||||
start = Time.now.to_f
|
it 'allows other threads in a process to continue while waiting' do
|
||||||
sem = Semaphore.new
|
start = Time.now.to_f
|
||||||
was_set = false
|
sem = Semaphore.new
|
||||||
t2 = nil
|
was_set = false
|
||||||
|
t2 = nil
|
||||||
|
|
||||||
sem.synchronize do
|
sem.synchronize do
|
||||||
t1 = Thread.new do
|
t1 = Thread.new do
|
||||||
# give t2 a chance to wait on the lock, then set the flag
|
# give t2 a chance to wait on the lock, then set the flag
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
was_set = true
|
was_set = true
|
||||||
end
|
|
||||||
|
|
||||||
t2 = Thread.new do
|
|
||||||
begin
|
|
||||||
sem.try_wait(10.0)
|
|
||||||
rescue Errno::ETIMEDOUT
|
|
||||||
# success
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
t2 = Thread.new do
|
||||||
|
begin
|
||||||
|
sem.try_wait(10.0)
|
||||||
|
rescue Errno::ETIMEDOUT
|
||||||
|
# success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# t1 should set the flag and die while t2 is still waiting on the lock
|
||||||
|
t1.join
|
||||||
end
|
end
|
||||||
|
|
||||||
# t1 should set the flag and die while t2 is still waiting on the lock
|
was_set.must_equal true
|
||||||
t1.join
|
(Time.now.to_f - start).must be_lt(0.1)
|
||||||
|
|
||||||
|
t2.join
|
||||||
end
|
end
|
||||||
|
|
||||||
was_set.must_equal true
|
|
||||||
(Time.now.to_f - start).must be_lt(0.1)
|
|
||||||
|
|
||||||
t2.join
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue