| 1 | |||
| 2 | =head1 NAME | ||
| 3 | |||
| 4 | Util::Task::Simple - A completely uncoalescable, stupid implementation of Util::Task that just runs a closure. | ||
| 5 | |||
| 6 | =head1 SYNOPSIS | ||
| 7 | |||
| 8 | my $task = Util::Task::Simple->new(\&some_sub); | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | This Task implementation is about as stupid as they get, just running a given bit of code with no special magic. | ||
| 13 | Consequently it can't coalesce, and runs all of its tasks sequentially. It also can't be remoted. | ||
| 14 | |||
| 15 | It should only be used for quick prototyping, and any uses of it should be replaced with a more sensible | ||
| 16 | L<Util::Task> subclass before long. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | package Util::Task::Simple; | ||
| 21 | |||
| 22 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 1 | ▶ | use base qw(Util::Task); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 27 | 0 | my ($class, $code) = @_; | |
| 28 | |||
| 29 | 0 | return bless $code, $class; | |
| 30 | } | ||
| 31 | |||
| 32 | 0 | ▶ | sub execute_multi { |
|
Subroutine
execute_multi: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 33 | 0 | my ($class, $batching_key, $tasks, $results) = @_; | |
| 34 | |||
| 35 | 0 | foreach my $k (keys %$tasks) { | |
| 36 | 0 | my $task = $tasks->{$k}; | |
| 37 | 0 | $results->{$k} = $task->(); | |
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | 1 | 1; | |