array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'gearmanclient.jobstatus.php', 1 => 'GearmanClient::jobStatus', ), 'up' => array ( 0 => 'class.gearmanclient.php', 1 => 'GearmanClient', ), 'prev' => array ( 0 => 'gearmanclient.geterrno.php', 1 => 'GearmanClient::getErrno', ), 'next' => array ( 0 => 'gearmanclient.ping.php', 1 => 'GearmanClient::ping', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/gearman/gearmanclient/jobstatus.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL gearman >= 0.5.0)
GearmanClient::jobStatus -- gearman_job_status — Get the status of a background job
Nesne yönelimli kullanım (method):
Gets the status for a background job given a job handle. The status information will specify whether the job is known, whether the job is currently running, and the percentage completion.
job_handle
Gearman sunucusu tarafından atanmış iş işleyici
An array containing status information for the job corresponding to the supplied job handle. The first array element is a boolean indicating whether the job is even known, the second is a boolean indicating whether the job is still running, and the third and fourth elements correspond to the numerator and denominator of the fractional completion percentage, respectively.
Örnek 1 Monitor the status of a long running background job
<?php
/* create our object */
$gmclient= new GearmanClient();
/* add the default server */
$gmclient->addServer();
/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");
if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
echo "bad return code\n";
exit;
}
$done = false;
do
{
sleep(3);
$stat = $gmclient->jobStatus($job_handle);
if (!$stat[0]) // the job is known so it is not done
$done = true;
echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "\n";
}
while(!$done);
echo "done!\n";
?>
Yukarıdaki örnek şuna benzer bir çıktı üretir:
Running: true, numerator: 3, denomintor: 14 Running: true, numerator: 6, denomintor: 14 Running: true, numerator: 9, denomintor: 14 Running: true, numerator: 12, denomintor: 14 Running: false, numerator: 0, denomintor: 0 done!