From 1fb634df6681a3698e40e11b2e10850bb954cfdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 22 Apr 2021 14:53:14 +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 --- Database/ActiveRecord.php | 2 +- System/Channel.php | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index c0006194..06b4dce0 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -324,7 +324,7 @@ class ActiveRecord extends BaseActiveRecord /** @var Channel $channel */ $channel = Snowflake::app()->get('channel'); - return $channel->push($this, get_called_class()); + $channel->push($this, get_called_class()); } diff --git a/System/Channel.php b/System/Channel.php index 9e688803..ff557b70 100644 --- a/System/Channel.php +++ b/System/Channel.php @@ -8,7 +8,6 @@ use Closure; use Exception; use Snowflake\Abstracts\Component; use SplQueue; -use Swoole\Coroutine\Channel as CChannel; /** @@ -25,22 +24,18 @@ class Channel extends Component /** * @param mixed $value * @param string $name - * @return mixed * @throws Exception */ - public function push(mixed $value, string $name = ''): mixed + public function push(mixed $value, string $name = ''): void { $channel = $this->channelInit($name); - if ($channel->isFull()) { - return $this->addError('Channel is full.'); - } - return $channel->push($value); + $channel->enqueue($value); } /** * @param string $name - * @return bool|CChannel + * @return bool|SplQueue */ private function channelInit(string $name = ''): bool|SplQueue { @@ -82,7 +77,7 @@ class Channel extends Component return $channel->pop(); } if ($timeout !== null) { - $data = $channel->pop($timeout); + $data = $channel->dequeue(); } if (empty($data)) { $data = call_user_func($closure);