Codebase list libparallel-forkmanager-perl / upstream/1.03
Imported Upstream version 1.03 Damyan Ivanov 11 years ago
6 changed file(s) with 68 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
00 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)
14
25 1.02 Mon Dec 24 13:27:03 2012
36 - Fix test for Windows.
33 "Balazs Szabo (dLux)"
44 ],
55 "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",
77 "license" : [
88 "perl_5"
99 ],
4545 "url" : "http://code.google.com/p/perl-parallel-forkmanager/"
4646 }
4747 },
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 ]
4958 }
66 configure_requires:
77 ExtUtils::MakeMaker: 0
88 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'
1010 license: perl
1111 meta-spec:
1212 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2424 Storable: 0
2525 resources:
2626 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>'
2020 resources => {
2121 repository => 'http://code.google.com/p/perl-parallel-forkmanager/',
2222 },
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 ],
2332 },
2433 dist => {
2534 PREOP => $^X.' -MPod::Text -e "pod2text(q(lib/Parallel/ForkManager.pm))" > README'
7070 The comment letter indicates where the method should be run. P for
7171 parent, C for child.
7272
73 new $processes [, $tempdir] # P
73 new $processes
7474 Instantiate a new Parallel::ForkManager object. You must specify
7575 the maximum number of children to fork off. If you specify 0
7676 (zero), then no children will be forked. This is intended for
7979 The optional second parameter, $tempdir, is only used if you want
8080 the children to send back a reference to some data (see RETRIEVING
8181 DATASTRUCTURES below). If not provided, it is set to
82 $File::Temp::tempdir().
82 $File::Spec->tmpdir().
8383
8484 The new method will die if the temporary directory does not exist
8585 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 ]
8989 This method does the fork. It returns the pid of the child process
9090 for the parent, and 0 for the child process. If the $processes
9191 parameter for the constructor is 0 then, assuming you're in the
9595 It is used by the "run_on_finish" callback (see CALLBACKS) for
9696 identifying the finished process.
9797
98 finish [ $exit_code [, $data_structure_reference] ] # C
98 finish [ $exit_code [, $data_structure_reference] ]
9999 Closes the child process by exiting and accepts an optional exit
100100 code (default exit code is 0) which can be retrieved in the parent
101101 via callback. If the second optional parameter is provided, the
107107 and passed to the parent process. See RETRIEVING DATASTRUCTURES for
108108 more info.
109109
110 set_max_procs $processes # P
110 set_max_procs $processes
111111 Allows you to set a new maximum number of children to maintain.
112112
113 wait_all_children # P
113 wait_all_children
114114 You can call this method to wait for all the processes which have
115115 been forked. This is a blocking wait.
116116
121121
122122 The callbacks can be defined with the following methods:
123123
124 run_on_finish $code [, $pid ] # P
124 run_on_finish $code [, $pid ]
125125 You can define a subroutine which is called when a child is
126126 terminated. It is called in the parent process.
127127
134134 - core dump (1 if there was core dump at exit)
135135 - datastructure reference or undef (see RETRIEVING DATASTRUCTURES)
136136
137 run_on_start $code # P
137 run_on_start $code
138138 You can define a subroutine which is called when a child is started.
139139 It called after the successful startup of a child in the parent
140140 process.
144144 - pid of the process which has been started
145145 - identification of the process (if provided in the "start" method)
146146
147 run_on_wait $code, [$period] # P
147 run_on_wait $code, [$period]
148148 You can define a subroutine which is called when the child process
149149 needs to wait for the startup. If $period is not defined, then one
150150 call is done per child. If $period is defined, then $code is called
400400 dLux (Szabó, Balázs) <dlux@dlux.hu>
401401
402402 CREDITS
403 Gabor Szabo (szabgab@cpn.org) (co-maintainer)
404 Michael Gang (bug report)
403405 Noah Robin <sitz@onastick.net> (documentation tweaks)
404406 Chuck Hirstius <chirstius@megapathdsl.net> (callback exit status, example)
405407 Grant Hopwood <hopwoodg@valero.com> (win32 port)
410412 Hey! The above document had some coding errors, which are explained
411413 below:
412414
413 Around line 84:
414 Unterminated L<...> sequence
415
416 Around line 88:
417 Unterminated L<...> sequence
418
419415 Around line 415:
420416 Non-ASCII character seen before =encoding in 'Szabó,'. Assuming
421417 ISO8859-1
7474
7575 =over 5
7676
77 =item new $processes [, $tempdir] # P
77 =item new $processes
7878
7979 Instantiate a new Parallel::ForkManager object. You must specify the maximum
8080 number of children to fork off. If you specify 0 (zero), then no children
8282
8383 The optional second parameter, $tempdir, is only used if you want the
8484 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
8787 The new method will die if the temporary directory does not exist or it is not
8888 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 ]
9292
9393 This method does the fork. It returns the pid of the child process for
9494 the parent, and 0 for the child process. If the $processes parameter
9999 the "run_on_finish" callback (see CALLBACKS) for identifying the finished
100100 process.
101101
102 =item finish [ $exit_code [, $data_structure_reference] ] # C
102 =item finish [ $exit_code [, $data_structure_reference] ]
103103
104104 Closes the child process by exiting and accepts an optional exit code
105105 (default exit code is 0) which can be retrieved in the parent via callback.
110110 If the $data_structure_reference is provided, then it is serialized and
111111 passed to the parent process. See RETRIEVING DATASTRUCTURES for more info.
112112
113 =item set_max_procs $processes # P
113 =item set_max_procs $processes
114114
115115 Allows you to set a new maximum number of children to maintain.
116116
117 =item wait_all_children # P
117 =item wait_all_children
118118
119119 You can call this method to wait for all the processes which have been
120120 forked. This is a blocking wait.
130130
131131 =over 4
132132
133 =item run_on_finish $code [, $pid ] # P
133 =item run_on_finish $code [, $pid ]
134134
135135 You can define a subroutine which is called when a child is terminated. It is
136136 called in the parent process.
144144 - core dump (1 if there was core dump at exit)
145145 - datastructure reference or undef (see RETRIEVING DATASTRUCTURES)
146146
147 =item run_on_start $code # P
147 =item run_on_start $code
148148
149149 You can define a subroutine which is called when a child is started. It called
150150 after the successful startup of a child in the parent process.
154154 - pid of the process which has been started
155155 - identification of the process (if provided in the "start" method)
156156
157 =item run_on_wait $code, [$period] # P
157 =item run_on_wait $code, [$period]
158158
159159 You can define a subroutine which is called when the child process needs to wait
160160 for the startup. If $period is not defined, then one call is done per
422422
423423 =head1 CREDITS
424424
425 Gabor Szabo (szabgab@cpn.org) (co-maintainer)
426 Michael Gang (bug report)
425427 Noah Robin <sitz@onastick.net> (documentation tweaks)
426428 Chuck Hirstius <chirstius@megapathdsl.net> (callback exit status, example)
427429 Grant Hopwood <hopwoodg@valero.com> (win32 port)
438440 use File::Path ();
439441 use strict;
440442 use vars qw($VERSION);
441 $VERSION="1.02";
443 $VERSION="1.03";
442444 $VERSION = eval $VERSION;
443445
444446 sub new {
445 my ($c,$processes, $tempdir)=@_;
447 my ($c,$processes,$tempdir)=@_;
446448
447449 my $h={
448450 max_proc => $processes,
451453 parent_pid => $$,
452454 };
453455
456
454457 # determine temporary directory for storing data structures
455458 # add it to Parallel::ForkManager object so children can use it
456459 # We don't let it clean up so it won't do it in the child process
457460 # 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;
459466
460467 return bless($h,ref($c)||$c);
461468 };