Skip to content

Commit 28f92ad

Browse files
committed
Updated brittle Exchanger with timeout spec.
1 parent b041082 commit 28f92ad

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

spec/concurrent/exchanger_spec.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,15 @@ module Concurrent
5050
context 'with timeout' do
5151
it 'should block until timeout' do
5252

53-
latch = Concurrent::CountDownLatch.new(1)
5453
value = 0
5554
start = Time.now.to_f
5655

57-
t = Thread.new do
58-
value = exchanger.exchange(2, 0.2)
59-
latch.count_down
56+
future = Concurrent::Future.execute do
57+
exchanger.exchange(2, 0.2)
6058
end
61-
62-
latch.wait(1)
63-
59+
60+
future.value.should be_nil
6461
(Time.now.to_f - start).should >= 0.2
65-
t.status.should be_false
66-
value.should be_nil
6762
end
6863
end
6964
end

0 commit comments

Comments
 (0)