-
-
Notifications
You must be signed in to change notification settings - Fork 0
WorkerGroup
Provides an immutable view over a collection of workers created by the same manager.
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.
- Full name:
\FastForward\Fork\Worker\WorkerGroup - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\Fork\Worker\WorkerGroupInterface - This class is a Final class
Initializes the worker group.
public __construct(\FastForward\Fork\Manager\ForkManagerInterface $manager, \FastForward\Fork\Worker\WorkerInterface $workers): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$manager |
\FastForward\Fork\Manager\ForkManagerInterface | manager that created the grouped workers |
$workers |
\FastForward\Fork\Worker\WorkerInterface | Workers exposed through this immutable group. |
Returns the manager that created this worker group.
public getManager(): \FastForward\Fork\Manager\ForkManagerInterfaceReturn Value:
the manager associated with this group
Returns all tracked workers.
public all(): array<int,\FastForward\Fork\Worker\WorkerInterface>Returns a worker by its PID.
public get(int $pid): \FastForward\Fork\Worker\WorkerInterface|nullParameters:
| Parameter | Type | Description |
|---|---|---|
$pid |
int | the process identifier of the worker |
Return Value:
the matching worker or null if not found
Waits until all workers in this group have finished.
public wait(): voidSends a signal to all workers in this group.
public kill(\FastForward\Fork\Signal\Signal $signal = \FastForward\Fork\Signal\Signal::Terminate): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$signal |
\FastForward\Fork\Signal\Signal | the signal to send to each worker |
Returns the workers that are currently running.
public getRunning(): array<int,\FastForward\Fork\Worker\WorkerInterface>Returns the workers that are no longer running.
public getStopped(): array<int,\FastForward\Fork\Worker\WorkerInterface>Returns an iterator for the tracked workers.
public getIterator(): \Traversable<int,\FastForward\Fork\Worker\WorkerInterface>Return Value:
iterator over workers
Returns the number of tracked workers.
public count(): intReturn Value:
total number of workers in the group