<?php
Swoole\Server->on('task', callback $callback)
The event name
callback function
if success, it returns TRUE, otherwise it returns FALSE.
Executue the callback function when receving Task
.
The event Task
is emitted when a Worker Process
sending task data to a Task Worker Process
pool.
The Task Worker Process
receiveing task data calls the callback function registered on the event task
.
When a Task Worker Process
is processing the task, it's status is changed to be BUSY and the status is changed to be IDLE when finishing the task.
In the callback function registered on event task
, the return value of this function is the result of task will be sent to the Worker Process
senting the task. You can also return the result of a task by call Swoole\Server->finish()
.
When the worker process has received the task result, the event finish
is triggered and execute the callback function on event finish
.
<?php
function (Swoole\Server $server, int $task_id, int $from_worker_id, mixed $data) {
}