IPC::QWorker - processing a queue in parallel
version 0.08
my $qworker = IPC::QWorker->new(); $qworker->create_workers(10, 'dump' => sub { my $ctx = shift(); print $$.": ".Dumper(@_)."\n"; $ctx->{'count'}++; }, '_init' => sub { my $ctx = shift(); $ctx->{'count'} = 0 ; }, '_destroy' => sub { my $ctx = shift(); print $$.": did ".$ctx->{'count'}." operations!\n"; } ); foreach $i (1..120) { $qworker->push_queue( IPC::QWorker::WorkUnit->new( 'cmd' => 'dump', 'params' => $i, ) ); } $qworker->process_queue(); # wait till queue is emtpy $qworker->flush_queue(); # then stop all workers $qworker->stop_workers();
None by default.
With this module you can fork a few child processes which know a few function calls you define while creating them. Later you can pass command with parameters into the queue which is distributed across the child processes thru pipes(with the Storable module).
perl, POSIX, Storable, IO::Select
Markus Benning <ich@markusbenning.de>
This software is copyright (c) 2013 by Markus Benning <ich@markusbenning.de>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install IPC::QWorker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IPC::QWorker
CPAN shell
perl -MCPAN -e shell install IPC::QWorker
For more information on module installation, please visit the detailed CPAN module installation guide.