Provides an immutable view over a collection of workers created by the same manager.
Description
This class acts as a value object representing a group of workers and offers convenience methods for querying and interacting with them collectively.
Instances of this class MUST be treated as immutable. Consumers SHOULD NOT attempt to modify the internal worker collection after instantiation.
Interfaces
Properties
Stores the workers tracked by this group.
Methods
Initializes the worker group.
Returns all tracked workers.
Returns the number of tracked workers.
Returns a worker by its PID.
Returns an iterator for the tracked workers.
Returns the manager that created this worker group.
Returns the workers that are currently running.
Returns the workers that are no longer running.
Sends a signal to all workers in this group.
Waits until all workers in this group have finished.
private
ForkManagerInterface
$manager
Stores the workers tracked by this group.
private
array<int, WorkerInterface>
$workers
=
[]
Initializes the worker group.
public
__construct(ForkManagerInterface
$manager, WorkerInterface
...$workers) : mixed
Parameters
Description
manager that created the grouped workers
Description
Workers exposed through this immutable group.
Returns all tracked workers.
public
all() : array<int, WorkerInterface>
Return values
Returns the number of tracked workers.
public
count() : int
Return values
Description
total number of workers in the group
Returns a worker by its PID.
public
get(
int
$pid) : WorkerInterface|null
Parameters
$pid
:
int
Description
the process identifier of the worker
Return values
Description
the matching worker or null if not found
Returns an iterator for the tracked workers.
public
getIterator() : Traversable<int, WorkerInterface>
Return values
Description
iterator over workers
Returns the manager that created this worker group.
public
getManager() : ForkManagerInterface
Return values
Description
the manager associated with this group
Returns the workers that are currently running.
public
getRunning() : array<int, WorkerInterface>
Return values
Returns the workers that are no longer running.
public
getStopped() : array<int, WorkerInterface>
Return values
Sends a signal to all workers in this group.
public
kill([Signal
$signal = Signal::Terminate]) : void
Parameters
Description
the signal to send to each worker
Waits until all workers in this group have finished.
public
wait() : void