CakeFest 2024: The Official CakePHP Conference

Pool::shutdown

(PECL pthreads >= 2.0.0)

Pool::shutdown停止所有的 Worker 对象

说明

publicPool::shutdown(): void

停止此 Pool 中所有的 Worker 对象。此方法调用会进入阻塞状态, 直到所有已经提交到这个 Pool 中的任务都执行完毕。

参数

此函数没有参数。

返回值

没有返回值。

示例

示例 #1 完全停止一个 Pool

<?php
class Task extends Threaded
{
public function
run()
{
usleep(500000);
}
}

$pool = new Pool(4);

for (
$i = 0; $i < 10; ++$i) {
$pool->submit(new Task());
}

$pool->shutdown(); // 进入阻塞状态,直到所有已经提交到 Pool 中的任务都执行完毕

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top