| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parallel::ForkManager::Child; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DLUX'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: role adopted by forked Parallel::ForkManager processes |
|
4
|
|
|
|
|
|
|
$Parallel::ForkManager::Child::VERSION = '2.04'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
121
|
|
|
121
|
|
179573
|
use strict; |
|
|
121
|
|
|
|
|
223
|
|
|
|
121
|
|
|
|
|
4663
|
|
|
8
|
121
|
|
|
121
|
|
1885
|
use warnings; |
|
|
121
|
|
|
|
|
303
|
|
|
|
121
|
|
|
|
|
8117
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
121
|
|
|
121
|
|
616
|
use Carp; |
|
|
121
|
|
|
|
|
338
|
|
|
|
121
|
|
|
|
|
8117
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
121
|
|
|
121
|
|
59360
|
use Moo::Role; |
|
|
121
|
|
|
|
|
2182407
|
|
|
|
121
|
|
|
|
|
744
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
0
|
0
|
sub is_child { 1 } |
|
15
|
0
|
|
|
0
|
0
|
0
|
sub is_parent { 0 } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub start { |
|
18
|
0
|
|
|
0
|
0
|
0
|
croak "Cannot start another process while you are in the child process"; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub finish { |
|
22
|
108
|
|
|
108
|
0
|
11063681
|
my ($s, $x, $r)=@_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
108
|
|
|
|
|
8594
|
$s->store($r); |
|
25
|
|
|
|
|
|
|
|
|
26
|
108
|
|
100
|
|
|
30490
|
CORE::exit($x || 0); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding UTF-8 |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Parallel::ForkManager::Child - role adopted by forked Parallel::ForkManager processes |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 VERSION |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
version 2.04 |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use 5.10.0; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use Parallel::ForkManager; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $fm = Parallel::ForkManager->new; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
say "parent does not consume the child role: ", $fm->does('Parallel::ForkManager::Child'); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$fm->start_child(sub{ |
|
56
|
|
|
|
|
|
|
sleep $_; |
|
57
|
|
|
|
|
|
|
say "but the child does: ", $fm->does('Parallel::ForkManager::Child'); |
|
58
|
|
|
|
|
|
|
say "child $_ says hi!" |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
}) for 1..3; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
When the parent L<Parallel::ForkManager> object forks a child process, |
|
65
|
|
|
|
|
|
|
its forked incarnation consumes this role. The role doesn't do much: it |
|
66
|
|
|
|
|
|
|
changes the returning values of C<is_child> and C<is_parent> in the way you'd expect, |
|
67
|
|
|
|
|
|
|
change C<start> so that it'd die if called from within the child, and change |
|
68
|
|
|
|
|
|
|
the implementation of C<finish> to potentially send data back to the parent process. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHORS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
dLux (Szabó, Balázs) <dlux@dlux.hu> |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Gabor Szabo <gabor@szabgab.com> |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This software is copyright (c) 2025, 2015 by Balázs Szabó. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
93
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |