swoole 协程通道 为了协程直接互相通讯传递数据
和go的通道很相似
Co un(function(){ $chan = new SwooleCoroutineChannel(1); SwooleCoroutine::create(function () use ($chan) { for($i = 0; $i < 100000; $i++) { co::sleep(1.0); $chan->push(['rand' => rand(1000, 9999), 'index' => $i]); echo "$i "; } }); SwooleCoroutine::create(function () use ($chan) { while(1) { $data = $chan->pop(); var_dump($data); } }); });