Skip to content

Commit 7f4c3a7

Browse files
iNecaspitr-ch
authored andcommitted
Add tests for edge future timeouts
1 parent 64db160 commit 7f4c3a7

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

spec/concurrent/edge/future_spec.rb

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,25 @@
184184
"sync on_failure #<RuntimeError: error>"]
185185
end
186186

187-
it 'supports setting timeout while waiting' do
188-
start_latch = Concurrent::CountDownLatch.new
189-
end_latch = Concurrent::CountDownLatch.new
190-
191-
future = Concurrent.future do
192-
start_latch.count_down
193-
end_latch.wait(1)
187+
[:wait, :wait!, :value, :value!, :reason, :result].each do |method_with_timeout|
188+
it "#{ method_with_timeout } supports setting timeout" do
189+
start_latch = Concurrent::CountDownLatch.new
190+
end_latch = Concurrent::CountDownLatch.new
191+
192+
future = Concurrent.future do
193+
start_latch.count_down
194+
end_latch.wait(1)
195+
end
196+
197+
start_latch.wait(1)
198+
future.send(method_with_timeout, 0.1)
199+
expect(future).not_to be_completed
200+
end_latch.count_down
201+
future.wait
194202
end
195-
196-
start_latch.wait(1)
197-
future.wait(0.1)
198-
expect(future).not_to be_completed
199-
end_latch.count_down
200-
future.wait
201203
end
202204

205+
203206
it 'chains' do
204207
future0 = Concurrent.future { 1 }.then { |v| v + 2 } # both executed on default FAST_EXECUTOR
205208
future1 = future0.then(:fast) { raise 'boo' } # executed on IO_EXECUTOR

0 commit comments

Comments
 (0)