改名
This commit is contained in:
+5
-3
@@ -4,6 +4,7 @@
|
|||||||
namespace Snowflake;
|
namespace Snowflake;
|
||||||
|
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Snowflake\Abstracts\Component;
|
use Snowflake\Abstracts\Component;
|
||||||
use Swoole\Coroutine\Channel as CChannel;
|
use Swoole\Coroutine\Channel as CChannel;
|
||||||
@@ -68,20 +69,21 @@ class Channel extends Component
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Closure $closure
|
||||||
* @param int $timeout
|
* @param int $timeout
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function pop($timeout = 1, string $name = ''): mixed
|
public function pop(Closure $closure, $timeout = 1, string $name = ''): mixed
|
||||||
{
|
{
|
||||||
if ($channel = $this->channelInit(0, $name)) {
|
if (($channel = $this->channelInit(0, $name)) == false) {
|
||||||
return $this->addError('Channel is full.');
|
return $this->addError('Channel is full.');
|
||||||
}
|
}
|
||||||
if (!$channel->isEmpty()) {
|
if (!$channel->isEmpty()) {
|
||||||
return $channel->pop($timeout);
|
return $channel->pop($timeout);
|
||||||
}
|
}
|
||||||
return null;
|
return call_user_func($closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user