class Concurrent::Promise
def self.zip(*promises)
-
(Promise
-)
Options Hash:
(**opts)
-
:execute
(Boolean
) -- execute promise before returning -
:executor
(Executor
) -- when set use the given `Executor` instance.
Parameters:
-
opts
(Hash
) -- the configuration options -
promises
(Array
) -- -
promises
(Array
) --
Overloads:
-
zip(*promises, opts)
-
zip(*promises)
def self.zip(*promises) opts = promises.last.is_a?(::Hash) ? promises.pop.dup : {} opts[:executor] ||= ImmediateExecutor.new zero = if !opts.key?(:execute) || opts.delete(:execute) fulfill([], opts) else Promise.new(opts) { [] } end promises.reduce(zero) do |p1, p2| p1.flat_map do |results| p2.then do |next_result| results << next_result end end end end