Method: Concurrent::Futures#await_any

Defined in:
lib/concurrent/futures.rb

#await_any(*futures) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/concurrent/futures.rb', line 44

def await_any( *futures )
  threads = futures.map { |future| Thread.new { Futures::await future } }
  begin
    threads.index ThreadsWait.new( *threads ).wait_next
  ensure
    threads.each { |thread| thread.raise RuntimeError }
  end
end