Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
hsldymq committed Jul 3, 2019
1 parent 3f0f251 commit 2ea27bc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/06.send_custom_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@

echo "[Custom Message] Worker {$workerID} Has Processed A Message, Workers:{$dispatcher->countWorkers()}, Memory Usage:{$memory} Bytes.\n";
})
// 也可以在dispatcher启动的时候让worker进行一些初始化操作
->on('start', function (Dispatcher $dispatcher) {
$dispatcher->dispatchCustomMessage(new Message(101, 'dispatcher started'));
})
->on('processed', function (string $workerID, Dispatcher $dispatcher) {
$stat = $dispatcher->getStat();
$processed = $stat['processed'];
Expand Down

0 comments on commit 2ea27bc

Please sign in to comment.