array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'gearmanworker.work.php', 1 => 'GearmanWorker::work', ), 'up' => array ( 0 => 'class.gearmanworker.php', 1 => 'GearmanWorker', ), 'prev' => array ( 0 => 'gearmanworker.wait.php', 1 => 'GearmanWorker::wait', ), 'next' => array ( 0 => 'class.gearmanexception.php', 1 => 'GearmanException', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/gearman/gearmanworker/work.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(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
.
Esta função não possui parâmetros.
Exemplo #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());
}
?>