lib/puppeteer/concurrent_ruby_utils.rb in puppeteer-ruby-0.0.13 vs lib/puppeteer/concurrent_ruby_utils.rb in puppeteer-ruby-0.0.14
- old
+ new
@@ -1,14 +1,20 @@
# utility methods for Concurrent::Promises.
module Puppeteer::ConcurrentRubyUtils
+ # wait for all promises.
+ # REMARK: This method doesn't assure the order of calling.
+ # for example, await_all(async1, async2) calls calls2 -> calls1 often.
def await_all(*args)
if args.length == 1 && args[0].is_a?(Enumerable)
Concurrent::Promises.zip(*(args[0])).value!
else
Concurrent::Promises.zip(*args).value!
end
end
+ # wait for first promises.
+ # REMARK: This method doesn't assure the order of calling.
+ # for example, await_all(async1, async2) calls calls2 -> calls1 often.
def await_any(*args)
if args.length == 1 && args[0].is_a?(Enumerable)
Concurrent::Promises.any(*(args[0])).value!
else
Concurrent::Promises.any(*args).value!