Skip to content

Commit

Permalink
Broadcast messages async
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 23, 2023
1 parent 83cb60d commit 8873f02
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,17 @@ public function stop(?Cancellation $cancellation = null): void
}

/**
* Broadcast data to all workers, sending data to active {@see Cluster::getChannel()::receive()} listeners.
* Broadcast data to all workers, received by {@see Cluster::getChannel()::receive()} in workers.
*
* @param TSend $data
*/
public function broadcast(mixed $data): void
{
$futures = [];
foreach ($this->workers as $worker) {
$worker->send($data);
$futures[] = async($worker->send(...), $data);
}

Future\await($futures);
}
}

0 comments on commit 8873f02

Please sign in to comment.