« GearmanWorker::wait
GearmanException »

GearmanWorker::work

(PECL gearman >= 0.5.0)

GearmanWorker::work — Wait for and perform jobs

説明

public function GearmanWorker::work(): bool

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.

パラメータ

この関数にはパラメータはありません。

戻り値

成功した場合に true を、失敗した場合に false を返します。

例

例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   worker   work   reverse   Wait   perform   jobs   callback   return   addFunction   wait   GearmanException   gearman   Waits   assigned   calls   appropriate   Issues   last   Gearman   code   成功   example   create   default
関連する関数・ページ:
gearmanworker.wait   gearmanworker.addfunction   gearmanworker.clone   gearmanworker.options   gearmanworker.construct   gearmanworker.removeoptions