Action is used to run a task’s remote_actions in parallel on each of its hosts. Actions are created automatically in Rake::RemoteTask#enhance.
The block this action will execute.
The task this action is attached to.
An Array of threads, one for each host this action executes on.
Execute this action on hosts in parallel. Returns when block
has completed for each host.
# File lib/rake/remote_task.rb, line 677 def execute hosts, task, args hosts.each do |host| t = task.clone t.target_host = host thread = Thread.new(t) do |task2| Thread.current[:task] = task2 case block.arity when 1 block.call task2 else block.call task2, args end Thread.current[:task] = nil end @workers.add thread end @workers.list.each { |thr| thr.join } end
Creates a new Action that will run
block for task.
# File lib/rake/remote_task.rb, line 662 def initialize task, block @task = task @block = block @workers = ThreadGroup.new end