本文整理汇总了PHP中GearmanWorker::getErrno方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanWorker::getErrno方法的具体用法?PHP GearmanWorker::getErrno怎么用?PHP GearmanWorker::getErrno使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GearmanWorker
的用法示例。
在下文中一共展示了GearmanWorker::getErrno方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
* Checks for the required gearman extension,
* fetches the bootstrap and loads in the gearman worker
*
* @return Gearman_Worker
*/
public function __construct($bootstrap)
{
if (!extension_loaded('gearman')) {
throw new RuntimeException('The PECL::gearman extension is required.');
}
$this->_worker = $bootstrap->getWorker();
if (empty($this->_registerFunction)) {
throw new InvalidArgumentException(get_class($this) . ' must implement a registerFunction');
}
// allow for a small memory gap:
$memoryLimit = ($this->_memory + 128) * 1024 * 1024;
ini_set('memory_limit', $memoryLimit);
$this->_worker->addFunction($this->_registerFunction, array(&$this, 'work'));
$this->_worker->setTimeout($this->_timeout);
$this->init();
while ($this->_worker->work() || $this->_worker->returnCode() == GEARMAN_TIMEOUT) {
if ($this->_worker->returnCode() == GEARMAN_TIMEOUT) {
$this->timeout();
continue;
}
if ($this->_worker->returnCode() != GEARMAN_SUCCESS) {
$this->setError($this->_worker->returnCode() . ': ' . $this->_worker->getErrno() . ': ' . $this->_worker->error());
break;
}
}
$this->shutdown();
}
示例2: __construct
/**
* Constructor
* Checks for the required gearman extension,
* fetches the bootstrap and loads in the gearman worker
*
* @param Zend_Application_Bootstrap_BootstrapAbstract $bootstrap
* @return Zend_Gearman_Worker
*/
public function __construct(Zend_Application_Bootstrap_BootstrapAbstract $bootstrap)
{
if (!extension_loaded('gearman')) {
throw new RuntimeException('The PECL::gearman extension is required.');
}
$this->_bootstrap = $bootstrap;
$this->_worker = $this->_bootstrap->bootstrap('gearmanworker')->getResource('gearmanworker');
if (empty($this->_registerFunction)) {
throw new InvalidArgumentException(get_class($this) . ' must implement a registerFunction');
}
// allow for a small memory gap:
$memoryLimit = ($this->_memory + 128) * 1024 * 1024;
ini_set('memory_limit', $memoryLimit);
$this->_worker->addFunction($this->_registerFunction, array(&$this, 'work'));
$this->_worker->setTimeout($this->_timeout);
$this->init();
$check = 10;
$c = 0;
while (@$this->_worker->work() || $this->_worker->returnCode() == GEARMAN_TIMEOUT) {
$c++;
if ($this->_worker->returnCode() == GEARMAN_TIMEOUT) {
$this->timeout();
continue;
}
if ($this->_worker->returnCode() != GEARMAN_SUCCESS) {
$this->setError($this->_worker->returnCode() . ': ' . $this->_worker->getErrno() . ': ' . $this->_worker->error());
break;
}
if ($c % $check === 0 && $this->isMemoryOverflow()) {
break;
// we've consumed our memory and the worker needs to be restarted
}
}
$this->shutdown();
}