略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: GearmanWorker::work

2024-12-22

GearmanWorker::work

(PECL gearman >= 0.5.0)

GearmanWorker::workWait for and perform jobs

说明

public 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()); 
}

?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/gearmanworker.work.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3