Optimized code of concurrent to adapt hyperf engine. (#2742)

This commit is contained in:
李铭昕 2020-10-31 12:29:27 +08:00 committed by GitHub
parent 5cab34c07b
commit 2e7a349b51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -20,6 +20,7 @@
- Removed config `rate-limit.php`, please use `rate_limit.php` instead.
- Removed useless class `Hyperf\Resource\Response\ResponseEmitter`.
- Removed component `hyperf/paginator` from database's dependencies.
- Removed method `stats` from `Hyperf\Utils\Coroutine\Concurrent`.
## Changed

View File

@ -12,16 +12,14 @@ declare(strict_types=1);
namespace Hyperf\Utils\Coroutine;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Engine\Channel;
use Hyperf\ExceptionHandler\Formatter\FormatterInterface;
use Hyperf\Utils\ApplicationContext;
use Swoole\Coroutine;
use Swoole\Coroutine\Channel;
use Hyperf\Utils\Coroutine;
/**
* @method bool isFull()
* @method bool isEmpty()
* @method array stats()
* @method int length()
*/
class Concurrent
{
@ -43,7 +41,7 @@ class Concurrent
public function __call($name, $arguments)
{
if (in_array($name, ['isFull', 'isEmpty', 'length', 'stats'])) {
if (in_array($name, ['isFull', 'isEmpty'])) {
return $this->channel->{$name}(...$arguments);
}
}
@ -53,9 +51,14 @@ class Concurrent
return $this->limit;
}
public function length(): int
{
return $this->channel->getLength();
}
public function getLength(): int
{
return $this->channel->length();
return $this->channel->getLength();
}
public function getRunningCoroutineCount(): int