kumatann 2019-09-12 10:45 采纳率: 0%
浏览 228

为什么win10不支持php pthreads pool类和worker对象?

win7环境下,wampserver支持php pthreads pool类和worker对象。win10却不支持pool类的$this->worker->getConnection()连接数据库,网页直接报错,子进程自动重启,apache日志报错:Parent: child process 9256 exited with status 3221225477 -- Restarting

以下程序可以测试win10是否解决问题:

<?php
class WebWorker extends Worker {

    public function __construct(SafeLog $logger) {
        $this->logger = $logger;
    }

    protected $loger;
}

class WebWork extends Stackable {

    public function isComplete() {
        return $this->complete;
    }

    public function run() {
        $this->worker
            ->logger
            ->log("%s executing in Thread #%lu",
                  __CLASS__, $this->worker->getThreadId());
        $this->complete = true;
    }

    protected $complete;
}

class SafeLog extends Stackable {

    protected function log($message, $args = []) {
        $args = func_get_args();

        if (($message = array_shift($args))) {
            echo vsprintf(
                "{$message}\n", $args);
        }
    }
}

$pool = new Pool(8, \WebWorker::class, [new SafeLog()]);
$pool->submit($w=new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->submit(new WebWork());
$pool->shutdown();
$pool->collect(function($work){
    return $work->isComplete();
});
?>

win7系统正常运行结果:

WebWork executing in Thread #1708
WebWork executing in Thread #1708
WebWork executing in Thread #5996
WebWork executing in Thread #5996
WebWork executing in Thread #6012
WebWork executing in Thread #6012
WebWork executing in Thread #6016
WebWork executing in Thread #6016
WebWork executing in Thread #2524
WebWork executing in Thread #2524
WebWork executing in Thread #5312
WebWork executing in Thread #5312
WebWork executing in Thread #6000
WebWork executing in Thread #5688
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2019-10-04 08:36
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?