Join 4,000+ others and never miss out on new tips, tutorials, and more.
pecl install openswoole-22.0.0 | composer require openswoole/core:22.1.2
<?php OpenSwoole\Server->finish(mixed $data)
The data can be any valid PHP type you want to send back to the worker process once the task has completed. The data here acts as the result of the task to send back to the worker process.
If successful, the data that is passed in is returned to the worker process
Used in task process for sending result to the worker process when the task is finished.
Once a task is deem complete you can send back any resulting data to the worker process and its registered
onFinish callback event, the
onFinish event is used to process result data from any completed tasks. Inside a task process, once it has completed you may use
OpenSwoole\Server->finish to send back data to the worker process and handle any results from what was done inside the task worker process.
This method can be thought of as a way to notify the worker process that the task completed and here are the results but if the worker process does not need to process any resulting data, you are not required to use this method or return any data from a task process.
You may call this method or return task data multiple times, this will then result in the
onFinish event being triggered multiple times.
You must only use this function within a task process and have your
onFinish event registered.