Module: Roby::TaskStructure::ExecutionAgentStart

Included in:
Roby::TaskEventGenerator
Defined in:
lib/roby/relations/executed_by.rb

Overview

This module is hooked in Roby::TaskEventGenerator to check that a task which is being started has a suitable execution agent, and to start it if it’s not the case

Instance Method Summary collapse

Instance Method Details

#calling(context) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/roby/relations/executed_by.rb', line 150

def calling(context)
    super if defined? super
    return unless symbol == :start
    return unless agent = task.execution_agent

    if agent.finished? || agent.finishing?
  raise CommandFailed.new(nil, self), "task #{task} has an execution agent but it is dead"
    elsif !agent.event(:ready).happened? && !agent.depends_on?(task)
  postpone(agent.event(:ready), "spawning execution agent #{agent} for #{self}") do
      if agent.pending?
    agent.event(:ready).if_unreachable(true) do |reason|
        self.emit_failed "execution agent #{agent} failed to initialize: #{reason}"
    end
    agent.start!
      end
  end
    end
end