GearmanWorker::work
(PECL gearman >= 0.5.0)
GearmanWorker::work — Wait for and perform jobs
说明
Waits for a job to be assigned and then calls the appropriate callback function.
Issues an E_WARNING with the last Gearman error if the return
code is not one of GEARMAN_SUCCESS, GEARMAN_IO_WAIT,
or GEARMAN_WORK_FAIL.
参数
此函数没有参数。
示例
示例 #1 GearmanWorker::work() example
<?php
# create the worker
$worker = new GearmanWorker();
# add the default job server (localhost)
$worker->addServer();
# add the reverse function
$worker->addFunction("reverse", "my_reverse_function");
# start te worker listening for job submissions
while ($worker->work());
function my_reverse_function($job)
{
return strrev($job->workload());
}
?>参见
- GearmanWorker::addFunction() - Register and add callback function
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
