MooseX::Workers::Engine - Provide the workhorse to MooseX::Workers
package MooseX::Workers; has Engine => ( isa => 'MooseX::Workers::Engine', is => 'ro', lazy => 1, required => 1, default => sub { MooseX::Workers::Engine->new( visitor => $_[0] ) }, handles => [ qw( max_workers has_workers num_workers put_worker kill_worker ) ], );
MooseX::Workers::Engine provides the main functionality to MooseX::Workers. It wraps a POE::Session and
Hold a reference to our main object so we can use the callbacks on it.
An Integer specifying the maxium number of workers we have.
An ArrayRef of POE::Wheel::Run objects that are our workers.
Contains the POE::Session that controls the workers.
Helper method to post events to our internal manager session.
Helper method to call events to our internal manager session. This is synchronous and will block incoming data from the children if it takes too long to return.
Set the worker at $key
Retrieve the worker at $key
Remove the worker atx $key
Check to see if we have *any* workers currently. This is delegated to the MooseX::Workers::Engine object.
Return the current number of workers. This is delegated to the MooseX::Workers::Engine object.
Check to see if we have a manager session.
Remove the manager session.
The Metaclass for MooseX::Workers::Engine see Moose's documentation.
Create a POE::Wheel::Run object to handle $command. If $command holds a scalar, it will be executed as exec($scalar). Shell metacharacters will be expanded in this form. If $command holds an array reference, it will executed as exec(@$array). This form of exec() doesn't expand shell metacharacters. If $command holds a code reference, it will be called in the forked child process, and then the child will exit.
See POE::Wheel::Run for more details.
MooseX::Worker::Engine fires the following callbacks:
Called when the managing session is started
Called when the managing session stops
Called when we reach the maximum number of workers
Called when a child prints to STDOUT
Called when a child prints to STDERR
Called when there is an error condition detected with the child.
Called when a worker completes $command
Called when a worker starts $command
Called when the mangaging session recieves a SIG CHDL event
Chris Prather <perigrin@cpan.org>
<perigrin@cpan.org>
Copyright (c) 2007, Chris Prather <perigrin@cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install MooseX::Workers, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Workers
CPAN shell
perl -MCPAN -e shell install MooseX::Workers
For more information on module installation, please visit the detailed CPAN module installation guide.