@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // MUST use defer because it can exec whatever job be FIN or KILL |
| 34 | 34 | // otherwise conn will never be released |
| 35 | - yield defer(function ($stage) use (&$conn) { |
|
| 35 | + yield defer(function($stage) use (&$conn) { |
|
| 36 | 36 | if ($conn instanceof Poolable) { |
| 37 | 37 | $stage instanceof Broken ? $conn->destroy() : $conn->release(); |
| 38 | 38 | } elseif ($stage instanceof Poolable) { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // check interrupter |
| 47 | 47 | if ($interrupter) { |
| 48 | - $interrupter->then(function () use ($conn) { |
|
| 48 | + $interrupter->then(function() use ($conn) { |
|
| 49 | 49 | return $conn; |
| 50 | 50 | }); |
| 51 | 51 | } |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $this->heartbeat = new Heartbeat($options, $this->connections); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $this->closed()->then(function () { |
|
| 83 | + $this->closed()->then(function() { |
|
| 84 | 84 | $this->stopping(); |
| 85 | 85 | $this->stats->untrack(); |
| 86 | 86 | $this->connections->cleanup(); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // checking in getWaitQ |
| 225 | - while (($this->getWaitQ ?! $this->getWaitQ->isEmpty() : false) && $wait = $this->getWaitQ->dequeue()) { |
|
| 225 | + while (($this->getWaitQ ? !$this->getWaitQ->isEmpty() : false) && $wait = $this->getWaitQ->dequeue()) { |
|
| 226 | 226 | if ($wait->pended()) { |
| 227 | 227 | $wait->resolve($this->setBusying($conn)); |
| 228 | 228 | return; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | private function checking() : void |
| 277 | 277 | { |
| 278 | - $cleared = ! ($this->cIdleCount() + $this->cBusyCount()); |
|
| 278 | + $cleared = !($this->cIdleCount() + $this->cBusyCount()); |
|
| 279 | 279 | |
| 280 | 280 | if ($this->exiting) { |
| 281 | 281 | if ($this->pool && ($closed = $this->pool->closed())->pended() && $cleared) { |
@@ -317,8 +317,8 @@ discard block |
||
| 317 | 317 | ] |
| 318 | 318 | ); |
| 319 | 319 | $this->rsExpanding = $expandSize = $target - $busySize - $idleSize; |
| 320 | - while ($expandSize -- > 0) { |
|
| 321 | - go(function () { |
|
| 320 | + while ($expandSize-- > 0) { |
|
| 321 | + go(function() { |
|
| 322 | 322 | try { |
| 323 | 323 | /** |
| 324 | 324 | * @var Poolable $poolable |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | ] |
| 337 | 337 | ); |
| 338 | 338 | } |
| 339 | - $this->rsExpanding --; |
|
| 339 | + $this->rsExpanding--; |
|
| 340 | 340 | }); |
| 341 | 341 | } |
| 342 | 342 | return $expandSize; |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | ] |
| 353 | 353 | ); |
| 354 | 354 | $shrinkSize = ($busySize + $idleSize) - $target; |
| 355 | - while ($shrinkSize -- > 0) { |
|
| 355 | + while ($shrinkSize-- > 0) { |
|
| 356 | 356 | if ($this->staIdling->count() > 0) { |
| 357 | - if ($this->removeIdling(null, function ($_, Poolable $found) use ($forced) { |
|
| 357 | + if ($this->removeIdling(null, function($_, Poolable $found) use ($forced) { |
|
| 358 | 358 | if (($this->recycling && $this->recycling->idling($found->cid())) || $forced) { |
| 359 | 359 | return true; |
| 360 | 360 | } |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | break; |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | - ($closer = Promise::deferred())->then(function (Poolable $conn) { |
|
| 371 | + ($closer = Promise::deferred())->then(function(Poolable $conn) { |
|
| 372 | 372 | $this->setClosing($conn); |
| 373 | 373 | }); |
| 374 | 374 | ($got = array_shift($this->staBusying)) && $got->schedule(Poolable::RELEASED, $closer); |
| 375 | 375 | } |
| 376 | - return - $shrinkSize; |
|
| 376 | + return -$shrinkSize; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | return 0; |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | if (is_null($matcher)) { |
| 435 | - $matcher = static function (Poolable $present, Poolable $found) { |
|
| 435 | + $matcher = static function(Poolable $present, Poolable $found) { |
|
| 436 | 436 | return $present->cid() === $found->cid(); |
| 437 | 437 | }; |
| 438 | 438 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | $searched = 0; |
| 441 | 441 | $connections = $this->staIdling->count(); |
| 442 | 442 | |
| 443 | - while ($searched ++ < $connections) { |
|
| 443 | + while ($searched++ < $connections) { |
|
| 444 | 444 | $conn = $this->staIdling->pop(); |
| 445 | 445 | if ($matcher($any, $conn)) { |
| 446 | 446 | $close && $this->setClosing($conn); |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | |
| 84 | 84 | if ($created instanceof Promised) { |
| 85 | 85 | // deferred create instance |
| 86 | - $created->then(function (Poolable $created) { |
|
| 86 | + $created->then(function(Poolable $created) { |
|
| 87 | 87 | $created->pool($this->pool); |
| 88 | 88 | }); |
| 89 | 89 | return $created; |
@@ -36,9 +36,9 @@ |
||
| 36 | 36 | * @var Poolable $conn |
| 37 | 37 | */ |
| 38 | 38 | while (null !== $conn = $this->conn()->getIdled(false, false)) { |
| 39 | - $conn->heartbeat()->then(static function () use ($conn) { |
|
| 39 | + $conn->heartbeat()->then(static function() use ($conn) { |
|
| 40 | 40 | $conn->release(); |
| 41 | - }, static function () use ($conn) { |
|
| 41 | + }, static function() use ($conn) { |
|
| 42 | 42 | $conn->destroy(); |
| 43 | 43 | }); |
| 44 | 44 | } |
@@ -62,9 +62,9 @@ |
||
| 62 | 62 | return $this->closed; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - ($this->closed = Promise::deferred())->then(function () { |
|
| 65 | + ($this->closed = Promise::deferred())->then(function() { |
|
| 66 | 66 | $this->destroy(); |
| 67 | - }, function () { |
|
| 67 | + }, function() { |
|
| 68 | 68 | $this->destroy(); |
| 69 | 69 | }); |
| 70 | 70 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public static function watch(Closure $changed) : void |
| 44 | 44 | { |
| 45 | - new Worker(self::$chan ?? self::$chan = new Channel, static function (array $recv) use ($changed) { |
|
| 45 | + new Worker(self::$chan ?? self::$chan = new Channel, static function(array $recv) use ($changed) { |
|
| 46 | 46 | $changed(...$recv); |
| 47 | 47 | }); |
| 48 | 48 | } |