Class: AWS::Flow::Core::AsyncScope Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/flow/async_scope.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AsyncScope

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AsyncScope.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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

Instance Attribute Details

#failureObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/aws/flow/async_scope.rb', line 31

def failure
  @failure
end

#rootObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/aws/flow/async_scope.rb', line 31

def root
  @root
end

#root_contextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/aws/flow/async_scope.rb', line 31

def root_context
  @root_context
end

#stackTraceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/aws/flow/async_scope.rb', line 31

def stackTrace
  @stackTrace
end

Instance Method Details

#<<(task) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



105
106
107
108
# File 'lib/aws/flow/async_scope.rb', line 105

def <<(task)
  @root_context << task
  task.parent = @root_context
end

#cancel(error) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
# File 'lib/aws/flow/async_scope.rb', line 44

def cancel(error); @root_error_handler.cancel(error); end

#eventLoopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

In the presence of external dependencies, it is expected that #eventLoop is called every

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.

time after a change in the state in a dependency can unblock asynchronous execution.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# 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_scopeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/aws/flow/async_scope.rb', line 39

def get_closest_containing_scope
  @root_error_handler
end

#get_heirsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Collects all the heirs of a task for use in async_stack_dump



69
70
71
# File 'lib/aws/flow/async_scope.rb', line 69

def get_heirs
  @root_error_handler.get_heirs
end

#is_complete?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


34
35
36
# File 'lib/aws/flow/async_scope.rb', line 34

def is_complete?
  @root_context.complete
end