From b7a785f7a18b749e3507b67a7807768669e2e24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 29 Mar 2021 13:58:15 +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 --- System/Channel.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/System/Channel.php b/System/Channel.php index ce69e034..331c7613 100644 --- a/System/Channel.php +++ b/System/Channel.php @@ -4,6 +4,7 @@ namespace Snowflake; +use Closure; use Exception; use Snowflake\Abstracts\Component; use Swoole\Coroutine\Channel as CChannel; @@ -68,20 +69,21 @@ class Channel extends Component /** + * @param Closure $closure * @param int $timeout * @param string $name * @return mixed * @throws Exception */ - public function pop($timeout = 1, string $name = ''): mixed + public function pop(Closure $closure, $timeout = 1, string $name = ''): mixed { - if ($channel = $this->channelInit(0, $name)) { + if (($channel = $this->channelInit(0, $name)) == false) { return $this->addError('Channel is full.'); } if (!$channel->isEmpty()) { return $channel->pop($timeout); } - return null; + return call_user_func($closure); }