class Concurrent::Promise
def then(*args, &block)
-
executor
(ThreadPool
) -- An optional thread pool executor to be used -
rescuer
(Proc
) -- An optional rescue block to be executed if the -
executor
(ThreadPool
) -- An optional thread pool executor to be used -
rescuer
(Proc
) -- An optional rescue block to be executed if the
Overloads:
-
then(rescuer, executor: executor, &block)
-
then(rescuer, executor, &block)
Other tags:
- Yield: - The block operation to be performed asynchronously.
Returns:
-
(Promise)
- the new promise
def then(*args, &block) if args.last.is_a?(::Hash) executor = args.pop[:executor] rescuer = args.first else rescuer, executor = args end executor ||= @executor raise ArgumentError.new('rescuers and block are both missing') if rescuer.nil? && !block_given? block = Proc.new { |result| result } unless block_given? child = Promise.new( parent: self, executor: executor, on_fulfill: block, on_reject: rescuer ) synchronize do child.state = :pending if @state == :pending child.on_fulfill(apply_deref_options(@value)) if @state == :fulfilled child.on_reject(@reason) if @state == :rejected @children << child end child end