class AWS::Flow::Core::AsyncScope
@api private
Attributes
failure[RW]
root[RW]
root_context[RW]
stackTrace[RW]
Public Class Methods
new(&block)
click to toggle source
@api private
# File lib/aws/flow/async_scope.rb, line 47 def initialize(&block) @root_context = RootAsyncScope.new # 1 for the function that skips frames # 1 for the create function # 1 for the initialize of the backtrace # "./lib/aws/rubyflow/asyncBacktrace.rb:75:in `caller'" # "./lib/aws/rubyflow/asyncBacktrace.rb:21:in `create'" # "./lib/aws/rubyflow/asyncScope.rb:18:in `initialize'" @root_context.backtrace = AsyncBacktrace.create(nil, 3) @root_error_handler = BeginRescueEnsure.new(:parent => @root_context) begin @root_error_handler.begin lambda { block.call if ! block.nil? } @root_error_handler.rescue(Exception, lambda { |e| raise e }) end @root_context << @root_error_handler end
Public Instance Methods
<<(task)
click to toggle source
@api private
# File lib/aws/flow/async_scope.rb, line 105 def <<(task) @root_context << task task.parent = @root_context end
cancel(error)
click to toggle source
@api private
# File lib/aws/flow/async_scope.rb, line 44 def cancel(error); @root_error_handler.cancel(error); end
eventLoop()
click to toggle source
Execute all queued tasks. If execution of those tasks results in the addition of new tasks to the queue, execute them as well.
Unless there are external dependencies or bugs in the tasks to be executed, a single call to this method performs the complete asynchronous execution.
@note In the presence of external dependencies, it is expected that {AsyncScope#eventLoop} is called every time after a change in the state in a dependency can unblock asynchronous execution.
@api private
# File lib/aws/flow/async_scope.rb, line 83 def eventLoop #TODO Figure out when to raise Done raise "Done" if ! @root_task.alive? raise IllegalStateException, "Already complete" if is_complete? @root_context.eventLoop # TODO Does this need to be taken care of? It's supposed to protect # against people having errors that are classes, so like, passing # Exception into cancel. We might want to just catch that at the # entry point. if @root_context.failure if @root_context.failure.respond_to? :message failure_message = @root_context.failure.message + "\n" + @root_context.failure.backtrace.join("\n") raise @root_context.failure, failure_message else raise @root_context.failure end end return is_complete? end
get_closest_containing_scope()
click to toggle source
@api private
# File lib/aws/flow/async_scope.rb, line 39 def get_closest_containing_scope @root_error_handler end
get_heirs()
click to toggle source
Collects all the heirs of a task for use in async_stack_dump @api private
# File lib/aws/flow/async_scope.rb, line 69 def get_heirs @root_error_handler.get_heirs end
is_complete?()
click to toggle source
@api private
# File lib/aws/flow/async_scope.rb, line 34 def is_complete? @root_context.complete end