| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Minion::Util; |
|
2
|
3
|
|
|
3
|
|
153333
|
use Mojo::Base -strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
1336
|
use Exporter qw(import); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
911
|
|
|
5
|
|
|
|
|
|
|
our @EXPORT_OK = qw(desired_tasks); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub desired_tasks { |
|
8
|
7
|
|
|
7
|
1
|
246872
|
my ($limits, $available_tasks, $active_tasks) = @_; |
|
9
|
|
|
|
|
|
|
|
|
10
|
7
|
|
|
|
|
14
|
my %count; |
|
11
|
7
|
|
|
|
|
31
|
$count{$_}++ for @$active_tasks; |
|
12
|
|
|
|
|
|
|
|
|
13
|
7
|
|
|
|
|
12
|
my @desired; |
|
14
|
7
|
|
|
|
|
13
|
for my $task (@$available_tasks) { |
|
15
|
13
|
|
100
|
|
|
44
|
my $count = $count{$task} // 0; |
|
16
|
13
|
|
|
|
|
24
|
my $limit = $limits->{$task}; |
|
17
|
13
|
100
|
66
|
|
|
58
|
push @desired, $task if !defined($limit) || $count < $limit; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
7
|
|
|
|
|
122
|
return \@desired; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
1; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=encoding utf8 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Minion::Util - Minion utility functions |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Minion::Util qw(desired_tasks); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
L provides utility functions for L. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
L implements the following functions, which can be imported individually. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 desired_tasks |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $desired_tasks = desired_trasks $limits, $available_tasks, $active_tasks; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Enforce limits and generate list of currently desired tasks. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ['bar'] |
|
50
|
|
|
|
|
|
|
desired_trasks {foo => 2}, ['foo', 'bar'], ['foo', 'foo']; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L, L, L, L, L. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |