(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
.
This function has no parameters.
Example #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());
}
?>
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant