Test Semaphore#try_wait() that doesn't end in ETIMEDOUT.

This commit is contained in:
Patrick Mahoney 2011-12-17 10:06:24 -06:00
parent ee939d407c
commit a0d0c7575c
1 changed files with 17 additions and 0 deletions

View File

@ -95,6 +95,23 @@ module ProcessShared
(Time.now.to_f - start).must be_gte(0.1) (Time.now.to_f - start).must be_gte(0.1)
end end
end end
it 'returns after waiting if another processes posts' do
Semaphore.open(0) do |sem|
start = Time.now.to_f
pid = fork do
sleep 0.01
sem.post
Kernel.exit!
end
sem.try_wait(0.1)
(Time.now.to_f - start).must be_lt(0.1)
::Process.wait(pid)
end
end
end end
end end
end end