Imported Upstream version 1.03
Damyan Ivanov
11 years ago
0 | 0 | Revision history for Perl extension Parallel::ForkManager. |
1 | ||
2 | 1.03 Wed Mar 6 11:14:13 2013 | |
3 | - Use second parameter from new() that was unused in the last few released. (Michael Gang) | |
1 | 4 | |
2 | 5 | 1.02 Mon Dec 24 13:27:03 2012 |
3 | 6 | - Fix test for Windows. |
3 | 3 | "Balazs Szabo (dLux)" |
4 | 4 | ], |
5 | 5 | "dynamic_config" : 1, |
6 | "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921", | |
6 | "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", | |
7 | 7 | "license" : [ |
8 | 8 | "perl_5" |
9 | 9 | ], |
45 | 45 | "url" : "http://code.google.com/p/perl-parallel-forkmanager/" |
46 | 46 | } |
47 | 47 | }, |
48 | "version" : "1.02" | |
48 | "version" : "1.03", | |
49 | "x_contributors" : [ | |
50 | "SZABGAB", | |
51 | "Michael Gang", | |
52 | "Noah Robin <sitz@onastick.net>", | |
53 | "Chuck Hirstius <chirstius@megapathdsl.net>", | |
54 | "Grant Hopwood <hopwoodg@valero.com>", | |
55 | "Mark Southern <mark_southern@merck.com>", | |
56 | "Ken Clarke <www.perlprogrammer.net>" | |
57 | ] | |
49 | 58 | } |
6 | 6 | configure_requires: |
7 | 7 | ExtUtils::MakeMaker: 0 |
8 | 8 | dynamic_config: 1 |
9 | generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921' | |
9 | generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' | |
10 | 10 | license: perl |
11 | 11 | meta-spec: |
12 | 12 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
24 | 24 | Storable: 0 |
25 | 25 | resources: |
26 | 26 | repository: http://code.google.com/p/perl-parallel-forkmanager/ |
27 | version: 1.02 | |
27 | version: 1.03 | |
28 | x_contributors: | |
29 | - SZABGAB | |
30 | - 'Michael Gang' | |
31 | - 'Noah Robin <sitz@onastick.net>' | |
32 | - 'Chuck Hirstius <chirstius@megapathdsl.net>' | |
33 | - 'Grant Hopwood <hopwoodg@valero.com>' | |
34 | - 'Mark Southern <mark_southern@merck.com>' | |
35 | - 'Ken Clarke <www.perlprogrammer.net>' |
20 | 20 | resources => { |
21 | 21 | repository => 'http://code.google.com/p/perl-parallel-forkmanager/', |
22 | 22 | }, |
23 | x_contributors => [ | |
24 | 'SZABGAB', | |
25 | 'Michael Gang', | |
26 | 'Noah Robin <sitz@onastick.net>', | |
27 | 'Chuck Hirstius <chirstius@megapathdsl.net>', | |
28 | 'Grant Hopwood <hopwoodg@valero.com>', | |
29 | 'Mark Southern <mark_southern@merck.com>', | |
30 | 'Ken Clarke <www.perlprogrammer.net>', | |
31 | ], | |
23 | 32 | }, |
24 | 33 | dist => { |
25 | 34 | PREOP => $^X.' -MPod::Text -e "pod2text(q(lib/Parallel/ForkManager.pm))" > README' |
70 | 70 | The comment letter indicates where the method should be run. P for |
71 | 71 | parent, C for child. |
72 | 72 | |
73 | new $processes [, $tempdir] # P | |
73 | new $processes | |
74 | 74 | Instantiate a new Parallel::ForkManager object. You must specify |
75 | 75 | the maximum number of children to fork off. If you specify 0 |
76 | 76 | (zero), then no children will be forked. This is intended for |
79 | 79 | The optional second parameter, $tempdir, is only used if you want |
80 | 80 | the children to send back a reference to some data (see RETRIEVING |
81 | 81 | DATASTRUCTURES below). If not provided, it is set to |
82 | $File::Temp::tempdir(). | |
82 | $File::Spec->tmpdir(). | |
83 | 83 | |
84 | 84 | The new method will die if the temporary directory does not exist |
85 | 85 | or it is not a directory, whether you provided this parameter or |
86 | the $"File::Temp::tempdir() is used." | |
87 | ||
88 | start [ $process_identifier ] # P | |
86 | the $File::Spec->tmpdir() is used. | |
87 | ||
88 | start [ $process_identifier ] | |
89 | 89 | This method does the fork. It returns the pid of the child process |
90 | 90 | for the parent, and 0 for the child process. If the $processes |
91 | 91 | parameter for the constructor is 0 then, assuming you're in the |
95 | 95 | It is used by the "run_on_finish" callback (see CALLBACKS) for |
96 | 96 | identifying the finished process. |
97 | 97 | |
98 | finish [ $exit_code [, $data_structure_reference] ] # C | |
98 | finish [ $exit_code [, $data_structure_reference] ] | |
99 | 99 | Closes the child process by exiting and accepts an optional exit |
100 | 100 | code (default exit code is 0) which can be retrieved in the parent |
101 | 101 | via callback. If the second optional parameter is provided, the |
107 | 107 | and passed to the parent process. See RETRIEVING DATASTRUCTURES for |
108 | 108 | more info. |
109 | 109 | |
110 | set_max_procs $processes # P | |
110 | set_max_procs $processes | |
111 | 111 | Allows you to set a new maximum number of children to maintain. |
112 | 112 | |
113 | wait_all_children # P | |
113 | wait_all_children | |
114 | 114 | You can call this method to wait for all the processes which have |
115 | 115 | been forked. This is a blocking wait. |
116 | 116 | |
121 | 121 | |
122 | 122 | The callbacks can be defined with the following methods: |
123 | 123 | |
124 | run_on_finish $code [, $pid ] # P | |
124 | run_on_finish $code [, $pid ] | |
125 | 125 | You can define a subroutine which is called when a child is |
126 | 126 | terminated. It is called in the parent process. |
127 | 127 | |
134 | 134 | - core dump (1 if there was core dump at exit) |
135 | 135 | - datastructure reference or undef (see RETRIEVING DATASTRUCTURES) |
136 | 136 | |
137 | run_on_start $code # P | |
137 | run_on_start $code | |
138 | 138 | You can define a subroutine which is called when a child is started. |
139 | 139 | It called after the successful startup of a child in the parent |
140 | 140 | process. |
144 | 144 | - pid of the process which has been started |
145 | 145 | - identification of the process (if provided in the "start" method) |
146 | 146 | |
147 | run_on_wait $code, [$period] # P | |
147 | run_on_wait $code, [$period] | |
148 | 148 | You can define a subroutine which is called when the child process |
149 | 149 | needs to wait for the startup. If $period is not defined, then one |
150 | 150 | call is done per child. If $period is defined, then $code is called |
400 | 400 | dLux (Szabó, Balázs) <dlux@dlux.hu> |
401 | 401 | |
402 | 402 | CREDITS |
403 | Gabor Szabo (szabgab@cpn.org) (co-maintainer) | |
404 | Michael Gang (bug report) | |
403 | 405 | Noah Robin <sitz@onastick.net> (documentation tweaks) |
404 | 406 | Chuck Hirstius <chirstius@megapathdsl.net> (callback exit status, example) |
405 | 407 | Grant Hopwood <hopwoodg@valero.com> (win32 port) |
410 | 412 | Hey! The above document had some coding errors, which are explained |
411 | 413 | below: |
412 | 414 | |
413 | Around line 84: | |
414 | Unterminated L<...> sequence | |
415 | ||
416 | Around line 88: | |
417 | Unterminated L<...> sequence | |
418 | ||
419 | 415 | Around line 415: |
420 | 416 | Non-ASCII character seen before =encoding in 'Szabó,'. Assuming |
421 | 417 | ISO8859-1 |
74 | 74 | |
75 | 75 | =over 5 |
76 | 76 | |
77 | =item new $processes [, $tempdir] # P | |
77 | =item new $processes | |
78 | 78 | |
79 | 79 | Instantiate a new Parallel::ForkManager object. You must specify the maximum |
80 | 80 | number of children to fork off. If you specify 0 (zero), then no children |
82 | 82 | |
83 | 83 | The optional second parameter, $tempdir, is only used if you want the |
84 | 84 | children to send back a reference to some data (see RETRIEVING DATASTRUCTURES |
85 | below). If not provided, it is set to $L<File::Temp::tempdir(). | |
86 | ||
85 | below). If not provided, it is set to $L<File::Spec>->tmpdir(). | |
86 | ||
87 | 87 | The new method will die if the temporary directory does not exist or it is not |
88 | 88 | a directory, whether you provided this parameter or the |
89 | $L<File::Temp::tempdir() is used. | |
90 | ||
91 | =item start [ $process_identifier ] # P | |
89 | $L<File::Spec>->tmpdir() is used. | |
90 | ||
91 | =item start [ $process_identifier ] | |
92 | 92 | |
93 | 93 | This method does the fork. It returns the pid of the child process for |
94 | 94 | the parent, and 0 for the child process. If the $processes parameter |
99 | 99 | the "run_on_finish" callback (see CALLBACKS) for identifying the finished |
100 | 100 | process. |
101 | 101 | |
102 | =item finish [ $exit_code [, $data_structure_reference] ] # C | |
102 | =item finish [ $exit_code [, $data_structure_reference] ] | |
103 | 103 | |
104 | 104 | Closes the child process by exiting and accepts an optional exit code |
105 | 105 | (default exit code is 0) which can be retrieved in the parent via callback. |
110 | 110 | If the $data_structure_reference is provided, then it is serialized and |
111 | 111 | passed to the parent process. See RETRIEVING DATASTRUCTURES for more info. |
112 | 112 | |
113 | =item set_max_procs $processes # P | |
113 | =item set_max_procs $processes | |
114 | 114 | |
115 | 115 | Allows you to set a new maximum number of children to maintain. |
116 | 116 | |
117 | =item wait_all_children # P | |
117 | =item wait_all_children | |
118 | 118 | |
119 | 119 | You can call this method to wait for all the processes which have been |
120 | 120 | forked. This is a blocking wait. |
130 | 130 | |
131 | 131 | =over 4 |
132 | 132 | |
133 | =item run_on_finish $code [, $pid ] # P | |
133 | =item run_on_finish $code [, $pid ] | |
134 | 134 | |
135 | 135 | You can define a subroutine which is called when a child is terminated. It is |
136 | 136 | called in the parent process. |
144 | 144 | - core dump (1 if there was core dump at exit) |
145 | 145 | - datastructure reference or undef (see RETRIEVING DATASTRUCTURES) |
146 | 146 | |
147 | =item run_on_start $code # P | |
147 | =item run_on_start $code | |
148 | 148 | |
149 | 149 | You can define a subroutine which is called when a child is started. It called |
150 | 150 | after the successful startup of a child in the parent process. |
154 | 154 | - pid of the process which has been started |
155 | 155 | - identification of the process (if provided in the "start" method) |
156 | 156 | |
157 | =item run_on_wait $code, [$period] # P | |
157 | =item run_on_wait $code, [$period] | |
158 | 158 | |
159 | 159 | You can define a subroutine which is called when the child process needs to wait |
160 | 160 | for the startup. If $period is not defined, then one call is done per |
422 | 422 | |
423 | 423 | =head1 CREDITS |
424 | 424 | |
425 | Gabor Szabo (szabgab@cpn.org) (co-maintainer) | |
426 | Michael Gang (bug report) | |
425 | 427 | Noah Robin <sitz@onastick.net> (documentation tweaks) |
426 | 428 | Chuck Hirstius <chirstius@megapathdsl.net> (callback exit status, example) |
427 | 429 | Grant Hopwood <hopwoodg@valero.com> (win32 port) |
438 | 440 | use File::Path (); |
439 | 441 | use strict; |
440 | 442 | use vars qw($VERSION); |
441 | $VERSION="1.02"; | |
443 | $VERSION="1.03"; | |
442 | 444 | $VERSION = eval $VERSION; |
443 | 445 | |
444 | 446 | sub new { |
445 | my ($c,$processes, $tempdir)=@_; | |
447 | my ($c,$processes,$tempdir)=@_; | |
446 | 448 | |
447 | 449 | my $h={ |
448 | 450 | max_proc => $processes, |
451 | 453 | parent_pid => $$, |
452 | 454 | }; |
453 | 455 | |
456 | ||
454 | 457 | # determine temporary directory for storing data structures |
455 | 458 | # add it to Parallel::ForkManager object so children can use it |
456 | 459 | # We don't let it clean up so it won't do it in the child process |
457 | 460 | # but we have our own DESTROY to do that. |
458 | $h->{tempdir} = File::Temp::tempdir(CLEANUP => 0); | |
461 | if (not defined($tempdir) or not length($tempdir)) { | |
462 | $tempdir = File::Temp::tempdir(CLEANUP => 0); | |
463 | } | |
464 | die qq|Temporary directory "$tempdir" doesn't exist or is not a directory.| unless (-e $tempdir && -d _); # ensure temp dir exists and is indeed a directory | |
465 | $h->{tempdir} = $tempdir; | |
459 | 466 | |
460 | 467 | return bless($h,ref($c)||$c); |
461 | 468 | }; |