本文整理汇总了PHP中PhabricatorWorker::waitForTasks方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorWorker::waitForTasks方法的具体用法?PHP PhabricatorWorker::waitForTasks怎么用?PHP PhabricatorWorker::waitForTasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorWorker
的用法示例。
在下文中一共展示了PhabricatorWorker::waitForTasks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: waitForLeases
public static function waitForLeases(array $leases)
{
assert_instances_of($leases, 'DrydockLease');
$task_ids = array_filter(mpull($leases, 'getTaskID'));
PhabricatorWorker::waitForTasks($task_ids);
$unresolved = $leases;
while (true) {
foreach ($unresolved as $key => $lease) {
$lease->reload();
switch ($lease->getStatus()) {
case DrydockLeaseStatus::STATUS_ACTIVE:
unset($unresolved[$key]);
break;
case DrydockLeaseStatus::STATUS_RELEASED:
throw new Exception('Lease has already been released!');
case DrydockLeaseStatus::STATUS_EXPIRED:
throw new Exception('Lease has already expired!');
case DrydockLeaseStatus::STATUS_BROKEN:
throw new Exception('Lease has been broken!');
case DrydockLeaseStatus::STATUS_PENDING:
case DrydockLeaseStatus::STATUS_ACQUIRING:
break;
default:
throw new Exception('Unknown status??');
}
}
if ($unresolved) {
sleep(1);
} else {
break;
}
}
foreach ($leases as $lease) {
$lease->attachResource($lease->loadResource());
}
}