class AWS::Flow::Core::Task
@api private
Attributes
Public Class Methods
Creates a new task.
@param __context__
A task needs a reference to the __context__ that created it so that when the "task" macro is called it can find the __context__, which the new task should be added to.
@param block
A block of code that will be run by the task.
@api private
AWS::Flow::Core::FlowFiber::new
# 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
Public Instance Methods
Adds a task to this task’s context.
@param this_task
The task to add.
@api private
# File lib/aws/flow/tasks.rb, line 137 def <<(this_task) @__context__.parent << this_task end
Is the task alive?
@return Boolean
true if the task is alive and has not been canceled.
@api private
# File lib/aws/flow/tasks.rb, line 47 def alive? super && !@cancelled #!!@alive# && !@cancelled end
Prevents the execution of this particular task, if possible.
@param error
The error that is the cause of the cancellation.
@api private
# File lib/aws/flow/tasks.rb, line 113 def cancel(error) @cancelled = true @__context__.remove(self) end
Retrieves the executor for this task.
@return
The executor for this task.
@api private
# File lib/aws/flow/tasks.rb, line 58 def executor @__context__.executor end
Fails the given task with the specified error.
@param error
The error that is the cause of the failure.
@api private
# File lib/aws/flow/tasks.rb, line 124 def fail(this_task, error) @__context__.fail(this_task, error) end
Passes all ‘get_heirs` calls to the class that is holding the context, to ensure uniform handling of `get_heirs`.
@api private
# File lib/aws/flow/tasks.rb, line 86 def get_heirs @__context__.get_heirs end
Will always be false. Provides a common API for BeginRescueEnsure
to ensure they are maintaining their nonDaemonHeirsCount correctly.
@api private
# File lib/aws/flow/tasks.rb, line 94 def is_daemon? return false end
Removes a task from this task’s context.
@param this_task
The task to remove.
@api private
# File lib/aws/flow/tasks.rb, line 147 def remove(this_task) @__context__.remove(this_task) end
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.
@api private
# File lib/aws/flow/tasks.rb, line 103 def schedule @__context__ << self end