©
このドキュメントでは、 php中国語ネットマニュアル リリース
(PECL gearman >= 0.5.0)
GearmanJob::__construct — Create a GearmanJob instance
Creates a GearmanJob instance representing a job the worker is to complete.
此函数没有参数。
A GearmanJob object.
[#1] liv_romania at yahoo dot com [2015-07-19 20:35:00]
Usually you will not need to create a GearmanJob object. The GearmanJob instance will be passed to a registered function with the job server when GearmanWorker::addFunction is used:
<?php
// create the worker
$worker= new GearmanWorker();
// add the default job server (localhost)
$worker->addServer('127.0.0.1', 4730);
// define a variable to hold application data
$count = 0;
// add the reverse function
$worker->addFunction('reverse', 'my_reverse_function', $count);
// start the worker listening for job submissions
while ($worker->work());
function my_reverse_function(GearmanJob $job, &$count)
{
$count++;
return $count . ': ' . strrev($job->workload()) . "\n";
}
?>