WorkerGroupInterface
Defines an immutable group of workers.
Description
Implementations MUST represent a read-only collection of workers that were created by the same manager instance. The group SHALL provide consistent access, iteration, and batch operations over the underlying workers.
Consumers MAY use this abstraction to coordinate multiple workers as a single unit without managing them individually.
Methods
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.
Returns all tracked workers.
public
all() : array<int, WorkerInterface>
Description
The returned array MUST contain all workers belonging to this group and SHALL be indexed by their process identifiers (PID).
Return values
Description
all workers in the group
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
Description
If no worker exists for the given PID, the method MUST return 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>
Description
The iterator MUST provide read-only traversal over the worker collection.
Return values
Description
iterator over workers
Returns the manager that created this worker group.
public
getManager() : ForkManagerInterface
Description
The returned manager MUST be the same instance responsible for all workers contained in this group.
Return values
Description
the manager associated with this group
Returns the workers that are currently running.
public
getRunning() : array<int, WorkerInterface>
Description
Implementations MUST return only workers whose execution has not yet completed.
Return values
Description
running workers
Returns the workers that are no longer running.
public
getStopped() : array<int, WorkerInterface>
Description
Implementations MUST return only workers that have already terminated or are no longer active.
Return values
Description
stopped workers
Sends a signal to all workers in this group.
public
kill([Signal
$signal = Signal::Terminate]) : void
Description
Implementations MUST ensure that the signal is delivered only to workers belonging to this group.
Parameters
Description
the signal to send to each worker
Waits until all workers in this group have finished.
public
wait() : void
Description
Implementations MUST block until all workers have terminated or have been fully reconciled by the manager.