1MooseX::Workers::EngineU(s3e)r Contributed Perl DocumentaMtoioosneX::Workers::Engine(3)
2
3
4

NAME

6       MooseX::Workers::Engine - Provide the workhorse to MooseX::Workers
7

SYNOPSIS

9           package MooseX::Workers;
10
11           has Engine => (
12               isa      => 'MooseX::Workers::Engine',
13               is       => 'ro',
14               lazy     => 1,
15               required => 1,
16               default  => sub { MooseX::Workers::Engine->new( visitor => $_[0] ) },
17               handles  => [
18                   qw(
19                     max_workers
20                     has_workers
21                     num_workers
22                     put_worker
23                     kill_worker
24                     )
25               ],
26           );
27

DESCRIPTION

29       MooseX::Workers::Engine provides the main functionality to
30       MooseX::Workers. It wraps a POE::Session and as many POE::Wheel::Run
31       objects as it needs.
32

ATTRIBUTES

34       visitor
35           Hold a reference to our main object so we can use the callbacks on
36           it.
37
38       max_workers
39           An Integer specifying the maximum number of workers we have.
40
41       workers
42           An ArrayRef of POE::Wheel::Run objects that are our workers.
43
44       session
45           Contains the POE::Session that controls the workers.
46

METHODS

48       yield
49           Helper method to post events to our internal manager session.
50
51       call
52           Helper method to call events to our internal manager session.  This
53           is synchronous and will block incoming data from the children if it
54           takes too long to return.
55
56       set_worker($key)
57           Set the worker at $key
58
59       get_worker($key)
60           Retrieve the worker at $key
61
62       delete_worker($key)
63           Remove the worker atx $key
64
65       has_workers
66           Check to see if we have *any* workers currently. This is delegated
67           to the MooseX::Workers::Engine object.
68
69       num_workers
70           Return the current number of workers. This is delegated to the
71           MooseX::Workers::Engine object.
72
73       has_manager
74           Check to see if we have a manager session.
75
76       remove_manager
77           Remove the manager session.
78
79       meta
80           The Metaclass for MooseX::Workers::Engine see Moose's
81           documentation.
82

EVENTS

84       add_worker ($command)
85           Create a POE::Wheel::Run object to handle $command. If $command
86           holds a scalar, it will be executed as exec($scalar).  Shell
87           metacharacters will be expanded in this form. If $command holds an
88           array reference, it will executed as exec(@$array). This form of
89           exec() doesn't expand shell metacharacters.  If $command holds a
90           code reference, it will be called in the forked child process, and
91           then the child will exit.
92
93           See POE::Wheel::Run for more details.
94

INTERFACE

96       MooseX::Worker::Engine fires the following callbacks to its visitor
97       object:
98
99       worker_manager_start
100           Called when the managing session is started.
101
102       worker_manager_stop
103           Called when the managing session stops.
104
105       max_workers_reached
106           Called when we reach the maximum number of workers.
107
108       worker_stdout
109           Called when a child prints to STDOUT.
110
111       worker_stderr
112           Called when a child prints to STDERR.
113
114       worker_error
115           Called when there is an error condition detected with the child.
116
117       worker_done
118           Called when a worker completes $command.
119
120       worker_started
121           Called when a worker starts $command.
122
123       sig_child($PID, $ret)
124           Called when the managing session receives a SIG CHLD event.
125
126       sig_*
127           Called when the underlying POE Kernel receives a signal; this is
128           not limited to OS signals (ie. what you'd usually handle in Perl's
129           %SIG) so will also accept arbitrary POE signals (sent via
130           POE::Kernel->signal), but does exclude SIGCHLD/SIGCHILD, which is
131           instead handled by sig_child above.
132
133           These interface methods are automatically inserted when
134           MooseX::Worker::Engine detects that the visitor object contains any
135           methods beginning with sig_.  Signals are case-sensitive, so if you
136           wish to handle a TERM signal, you must define a sig_TERM() method.
137           Note also that this action is performed upon MooseX::Worker::Engine
138           startup, so any run-time modification of the visitor object is not
139           likely to be detected.
140
141
142
143perl v5.32.0                      2020-07-28        MooseX::Workers::Engine(3)
Impressum