Class: AWS::Flow::Core::Task Private
- Defined in:
- lib/aws/flow/tasks.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.
Direct Known Subclasses
Instance Attribute Summary collapse
- #__context__ ⇒ Object private
- #backtrace ⇒ Object private
- #block ⇒ Object readonly private
- #parent ⇒ Object private
- #result ⇒ Object readonly private
Instance Method Summary collapse
-
#<<(this_task) ⇒ Object
private
Adds a task to this task’s context.
-
#alive? ⇒ Boolean
private
Is the task alive?.
-
#cancel(error) ⇒ Object
private
Prevents the execution of this particular task, if possible.
-
#executor ⇒ Object
private
Retrieves the executor for this task.
-
#fail(this_task, error) ⇒ Object
private
Fails the given task with the specified error.
-
#get_heirs ⇒ Object
private
Passes all ‘get_heirs` calls to the class that is holding the context, to ensure uniform handling of `get_heirs`.
-
#initialize(__context__, &block) ⇒ Task
constructor
private
Creates a new task.
-
#is_daemon? ⇒ Boolean
private
Will always be false.
-
#remove(this_task) ⇒ Object
private
Removes a task from this task’s context.
-
#schedule ⇒ Object
private
Used by Future#signal to schedule the task for re-evaluation.
Methods inherited from FlowFiber
#[], [], []=, #[]=, finalize, unset
Constructor Details
#initialize(__context__, &block) ⇒ Task
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.
Creates a new task.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/aws/flow/tasks.rb', line 36 def initialize(__context__, &block) @__context__ = __context__ @result = Future.new @block = block # Is the task alive? # # @return Boolean # true if the task is alive and has not been canceled. # # @api private def alive? super && !@cancelled #!!@alive# && !@cancelled end # Retrieves the executor for this task. # # @return # The executor for this task. # # @api private def executor @__context__.executor end super() do begin # Not return because 1.9 will freak about local jump problems if you # try to return, as this is inside a block. next if @cancelled @result.set(lambda(&block).call) next if @cancelled @__context__.remove(self) rescue Exception => e if @backtrace != e backtrace = AsyncBacktrace.create_from_exception(@backtrace, e) e.set_backtrace(backtrace.backtrace) if backtrace end @__context__.fail(self, e) ensure end end end |
Instance Attribute Details
#__context__ ⇒ 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.
24 25 26 |
# File 'lib/aws/flow/tasks.rb', line 24 def __context__ @__context__ end |
#backtrace ⇒ 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.
24 25 26 |
# File 'lib/aws/flow/tasks.rb', line 24 def backtrace @backtrace end |
#block ⇒ Object (readonly)
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.
23 24 25 |
# File 'lib/aws/flow/tasks.rb', line 23 def block @block end |
#parent ⇒ 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.
24 25 26 |
# File 'lib/aws/flow/tasks.rb', line 24 def parent @parent end |
#result ⇒ Object (readonly)
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.
23 24 25 |
# File 'lib/aws/flow/tasks.rb', line 23 def result @result end |
Instance Method Details
#<<(this_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.
Adds a task to this task’s context.
137 138 139 |
# File 'lib/aws/flow/tasks.rb', line 137 def <<(this_task) @__context__.parent << this_task end |
#alive? ⇒ 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.
Is the task alive?
47 48 49 50 |
# File 'lib/aws/flow/tasks.rb', line 47 def alive? super && !@cancelled #!!@alive# && !@cancelled 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.
Prevents the execution of this particular task, if possible.
113 114 115 116 |
# File 'lib/aws/flow/tasks.rb', line 113 def cancel(error) @cancelled = true @__context__.remove(self) end |
#executor ⇒ 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.
Retrieves the executor for this task.
58 59 60 |
# File 'lib/aws/flow/tasks.rb', line 58 def executor @__context__.executor end |
#fail(this_task, 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.
Fails the given task with the specified error.
124 125 126 |
# File 'lib/aws/flow/tasks.rb', line 124 def fail(this_task, error) @__context__.fail(this_task, error) end |
#get_heirs ⇒ 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.
Passes all ‘get_heirs` calls to the class that is holding the context, to ensure uniform handling of `get_heirs`.
86 87 88 |
# File 'lib/aws/flow/tasks.rb', line 86 def get_heirs @__context__.get_heirs end |
#is_daemon? ⇒ 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.
Will always be false. Provides a common API for BeginRescueEnsure to ensure they are maintaining their nonDaemonHeirsCount correctly.
94 95 96 |
# File 'lib/aws/flow/tasks.rb', line 94 def is_daemon? return false end |
#remove(this_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.
Removes a task from this task’s context.
147 148 149 |
# File 'lib/aws/flow/tasks.rb', line 147 def remove(this_task) @__context__.remove(this_task) end |
#schedule ⇒ 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.
Used by Future#signal to schedule the task for re-evaluation.
This will simply add the task back to the list of things to be run in the parent’s event loop.
103 104 105 |
# File 'lib/aws/flow/tasks.rb', line 103 def schedule @__context__ << self end |