line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Job::Async::Worker::Memory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
826
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use parent qw(Job::Async::Worker); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Job::Async::Worker::Memory - basic in-memory job worker for L |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This is intended as an example, and for testing code. It's not |
17
|
|
|
|
|
|
|
very useful in a real application. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
130
|
use Future::Utils qw(repeat); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
529
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
0
|
7
|
sub start { Future->done } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub trigger { |
26
|
2
|
|
|
2
|
0
|
288
|
my ($self) = @_; |
27
|
|
|
|
|
|
|
$self->{active} ||= (repeat { |
28
|
2532
|
|
|
2532
|
|
41529
|
my $loop = $self->loop; |
29
|
2532
|
|
|
|
|
10357
|
my $f = $loop->new_future; |
30
|
|
|
|
|
|
|
$self->loop->later(sub { |
31
|
2532
|
50
|
|
|
|
232342
|
if(my $job = shift @Job::Async::Memory::PENDING_JOBS) { |
32
|
2532
|
|
|
|
|
4577
|
$self->process($job); |
33
|
|
|
|
|
|
|
} |
34
|
2532
|
|
|
|
|
298638
|
$f->done; |
35
|
2532
|
|
|
|
|
36926
|
}); |
36
|
2532
|
|
|
|
|
52788
|
$f; |
37
|
2532
|
|
|
2532
|
|
130522
|
} while => sub { 0+@Job::Async::Memory::PENDING_JOBS })->on_ready(sub { |
38
|
|
|
|
|
|
|
delete $self->{active} |
39
|
2
|
|
|
2
|
|
191
|
}) |
40
|
2
|
|
33
|
|
|
27
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub process { |
43
|
2532
|
|
|
2532
|
0
|
3507
|
my ($self, $job) = @_; |
44
|
2532
|
|
|
|
|
5835
|
$self->jobs->emit($job); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Tom Molesworth |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 LICENSE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright Tom Molesworth 2016-2017. Licensed under the same terms as Perl itself. |
56
|
|
|
|
|
|
|
|