在 PHP 的 Pthreads 中设置线程继承选项
Setting Thread Inheritance options in Pthreads for PHP
有没有什么方法可以指定线程在使用 Pool 时应该继承什么,就像在 Thread 中一样:
$thread = new MyThread();
$thread->start(PTHREADS_INHERIT_INI | PTHREADS_INHERIT_CONSTANTS);
我正在寻找一种方法来使用 Pool,例如:
$pool->shutdown(<options>);// doesn't work
我在文档中找不到任何方法。也许我遗漏了什么。
Pool
在 __construct
中取一个 Worker
class:
new Pool(8, MyWorker::class);
其中 MyWorker
看起来像:
class MyWorker {
public function start() {
return parent::start(PTHREADS_INHERIT_INI | PTHREADS_INHERIT_CONSTANTS);
}
}
有没有什么方法可以指定线程在使用 Pool 时应该继承什么,就像在 Thread 中一样:
$thread = new MyThread();
$thread->start(PTHREADS_INHERIT_INI | PTHREADS_INHERIT_CONSTANTS);
我正在寻找一种方法来使用 Pool,例如:
$pool->shutdown(<options>);// doesn't work
我在文档中找不到任何方法。也许我遗漏了什么。
Pool
在 __construct
中取一个 Worker
class:
new Pool(8, MyWorker::class);
其中 MyWorker
看起来像:
class MyWorker {
public function start() {
return parent::start(PTHREADS_INHERIT_INI | PTHREADS_INHERIT_CONSTANTS);
}
}