From ffc8f5db548aadca7a3669cfd6011481de3d7757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 12 Oct 2020 12:51:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/Kafka.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Kafka/Kafka.php b/Kafka/Kafka.php index 36c2bcff..d49df5d0 100644 --- a/Kafka/Kafka.php +++ b/Kafka/Kafka.php @@ -68,8 +68,13 @@ class Kafka extends \Snowflake\Process\Process $this->channel = new Channel(1000); Coroutine::create(function () { $group = new WaitGroup(); - while ([$topic, $part, $message] = $this->channel->pop()) { - $this->handlerExecute($group, $topic, $part, $message); + for ($i = 0; $i < 1000; $i++) { + $group->add(); + go(function () use ($group) { + while ([$topic, $part, $message] = $this->channel->pop()) { + $this->handlerExecute($group, $topic, $part, $message); + } + }); } $group->wait(); });