We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 21a23cd commit 047bc12Copy full SHA for 047bc12
spec/concurrent/exchanger_spec.rb
@@ -49,15 +49,20 @@ module Concurrent
49
50
context 'with timeout' do
51
it 'should block until timeout' do
52
- value = 0
53
54
- t = Thread.new { value = exchanger.exchange(2, 0.2) }
+ latch = Concurrent::CountDownLatch.new(1)
+ value = 0
55
+ start = Time.now.to_f
56
- sleep(0.1)
57
- t.status.should eq 'sleep'
+ t = Thread.new do
58
+ value = exchanger.exchange(2, 0.2)
59
+ latch.count_down
60
+ end
61
- sleep(0.2)
62
+ latch.wait(1)
63
64
+ (Time.now.to_f - start).should >= 0.2
65
+ t.status.should be_false
66
value.should be_nil
67
end
68
0 commit comments