Cinnamon
view release on metacpan or search on metacpan
lib/Cinnamon/Runner.pm view on Meta::CPAN
sub start {
my ($class, $hosts, $task) = @_;
my $all_results = {};
$hosts = [ @$hosts ];
my $task_name = $task->name;
my $concurrency_setting = CTX->get_param('concurrency') || {};
my $concurrency = $concurrency_setting->{$task_name} || scalar @$hosts;
while (my @target_hosts = splice @$hosts, 0, $concurrency) {
my @coros;
for my $host (@target_hosts) {
my $coro = async {
my $result = $class->execute($host, $task);
$all_results->{$host} = $result;
};
push @coros, $coro;
}
$_->join for @coros;
}
return $all_results;
}
sub execute {
my ($class, $host, $task) = @_;
my $result = { host => $host, error => 0 };
( run in 0.332 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )