改名
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Snowflake\Abstracts;
|
||||
|
||||
use Exception;
|
||||
|
||||
use HttpServer\Http\Context;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Coroutine\Channel;
|
||||
|
||||
@@ -99,6 +100,27 @@ abstract class Pool extends Component
|
||||
throw new Exception('Undefined system processing function.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param string $coroutineName
|
||||
* @param callable $createHandler
|
||||
*/
|
||||
public function createConnect(array $config, string $coroutineName, callable $createHandler): void
|
||||
{
|
||||
if (Context::hasContext('create:connect:' . $coroutineName)) {
|
||||
return;
|
||||
}
|
||||
Context::setContext('create:connect:' . $coroutineName, 1);
|
||||
|
||||
$client = call_user_func($createHandler, ...$config);
|
||||
|
||||
$this->push($coroutineName, $client);
|
||||
|
||||
Context::deleteId('create:connect:' . $coroutineName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return bool
|
||||
|
||||
Reference in New Issue
Block a user