qqq
This commit is contained in:
@@ -82,6 +82,17 @@ class Pool implements PoolInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function abandon(string $name): void
|
||||
{
|
||||
$this->channel($name)->abandon();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return array
|
||||
|
||||
@@ -22,6 +22,13 @@ interface PoolInterface
|
||||
public function get(string $name): mixed;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function abandon(string $name): void;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $data
|
||||
|
||||
+12
-2
@@ -76,7 +76,7 @@ class PoolItem
|
||||
public function push(mixed $item): void
|
||||
{
|
||||
if (is_null($item)) {
|
||||
$item = call_user_func($this->callback);
|
||||
return;
|
||||
}
|
||||
$this->_items->push($item);
|
||||
}
|
||||
@@ -126,13 +126,23 @@ class PoolItem
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function abandon(): void
|
||||
{
|
||||
$this->created -= 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $waite
|
||||
* @return mixed
|
||||
*/
|
||||
public function pop(int $waite = 10): mixed
|
||||
{
|
||||
if ($this->_items->isEmpty()) {
|
||||
if ($this->_items->isEmpty() && $this->created >= $this->maxCreated) {
|
||||
$this->created += 1;
|
||||
return call_user_func($this->callback);
|
||||
} else {
|
||||
return $this->_items->pop($waite);
|
||||
|
||||
Reference in New Issue
Block a user