本文整理汇总了PHP中Lock::nonblockingExecuteOnce方法的典型用法代码示例。如果您正苦于以下问题:PHP Lock::nonblockingExecuteOnce方法的具体用法?PHP Lock::nonblockingExecuteOnce怎么用?PHP Lock::nonblockingExecuteOnce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lock
的用法示例。
在下文中一共展示了Lock::nonblockingExecuteOnce方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* Perform an update.
*
* If enabled (default) this method will send a E_USER_NOTICE about the update.
*
* @see setNotice()
*/
public function perform(DataBackend $backend)
{
$isNotice = $this->notice;
$lock = new Lock(self::UPDATE_LOCK);
$lock->nonblockingExecuteOnce(function () use($backend, $isNotice) {
$backend->update();
if ($isNotice) {
trigger_error("bav's bank data was updated sucessfully.", E_USER_NOTICE);
}
});
}
示例2: testNonblockingExecuteOnce
/**
* Tests nonblockingExecuteOnce().
*
* @see Lock::nonblockingExecuteOnce()
*/
public function testNonblockingExecuteOnce()
{
$name = __FUNCTION__;
$isExecuted = false;
$isExecutedCheck = false;
$lock = new Lock($name);
$lock->nonblockingExecuteOnce(function () use(&$isExecuted, &$isExecutedCheck, $name) {
$isExecuted = true;
$checkLock = new Lock($name);
$checkLock->nonblockingExecuteOnce(function () use(&$isExecutedCheck) {
$isExecutedCheck = true;
});
});
$this->assertTrue($isExecuted);
$this->assertFalse($isExecutedCheck);
}