Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Jan 21, 2019
1 parent 3b8ed8a commit a188466
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/Pool/AbstractPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


use EasySwoole\Component\Pool\Exception\PoolEmpty;
use EasySwoole\Component\Pool\Exception\PoolNumError;
use EasySwoole\Component\Pool\Exception\PoolUnRegister;
use EasySwoole\Component\Pool\Exception\PoolObjectNumError;
use EasySwoole\Component\Pool\Exception\PoolException;
use EasySwoole\Utility\Random;
use Swoole\Coroutine\Channel;

Expand All @@ -31,7 +31,7 @@ public function __construct(PoolConf $conf)
{
if($conf->getMinObjectNum() >= $conf->getMaxObjectNum()){
$class = static::class;
throw new PoolNumError("pool max num is small than min num for {$class} error");
throw new PoolObjectNumError("pool max num is small than min num for {$class} error");
}
$this->conf = $conf;
$this->poolChannel = new Channel($conf->getMaxObjectNum() + 1);
Expand Down Expand Up @@ -198,7 +198,7 @@ public static function invoke(callable $call,float $timeout = null)
throw new PoolEmpty(static::class." pool is empty");
}
}else{
throw new PoolUnRegister(static::class." pool is unregister");
throw new PoolException(static::class." convert to pool error");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Pool/Exception/PoolEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasySwoole\Component\Pool\Exception;


class PoolEmpty extends \Exception
class PoolEmpty extends PoolException
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasySwoole\Component\Pool\Exception;


class PoolUnRegister extends \Exception
class PoolException extends \Exception
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace EasySwoole\Component\Pool\Exception;


class PoolNumError extends \Exception
class PoolObjectNumError extends PoolException
{

}
16 changes: 8 additions & 8 deletions src/Pool/PoolConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace EasySwoole\Component\Pool;


use EasySwoole\Component\Pool\Exception\PoolObjectNumError;

class PoolConf
{
protected $class;
Expand Down Expand Up @@ -83,12 +85,11 @@ public function getMaxObjectNum(): int
return $this->maxObjectNum;
}

/**
* @param int $maxObjectNum
* @return PoolConf
*/
public function setMaxObjectNum(int $maxObjectNum): PoolConf
{
if($this->minObjectNum >= $maxObjectNum){
throw new PoolObjectNumError('min num is bigger than max');
}
$this->maxObjectNum = $maxObjectNum;
return $this;
}
Expand Down Expand Up @@ -137,12 +138,11 @@ public function getMinObjectNum(): int
return $this->minObjectNum;
}

/**
* @param int $minObjectNum
* @return PoolConf
*/
public function setMinObjectNum(int $minObjectNum): PoolConf
{
if($minObjectNum >= $this->maxObjectNum){
throw new PoolObjectNumError('min num is bigger than max');
}
$this->minObjectNum = $minObjectNum;
return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Pool/TraitObjectInvoker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


use EasySwoole\Component\Pool\Exception\PoolEmpty;
use EasySwoole\Component\Pool\Exception\PoolUnRegister;
use EasySwoole\Component\Pool\Exception\PoolException;

trait TraitObjectInvoker
{
Expand All @@ -32,7 +32,7 @@ public static function invoke(callable $call,float $timeout = null)
throw new PoolEmpty(static::class." pool is empty");
}
}else{
throw new PoolUnRegister(static::class." pool is unregister");
throw new PoolException(static::class." convert to pool error");
}
}
}

0 comments on commit a188466

Please sign in to comment.