Compare commits

...

6 Commits

Author SHA1 Message Date
as2252258 536e4c9bc5 eee 2026-07-03 18:29:45 +08:00
as2252258 91be2eba20 eee 2026-07-03 10:42:54 +08:00
as2252258 d7f5f62c1c eee 2026-06-30 22:39:56 +08:00
as2252258 8b8bfa2a60 eee 2026-06-28 15:16:46 +08:00
as2252258 1ecf32bfa6 eee 2026-06-28 15:13:08 +08:00
as2252258 8c0c5b56c8 eee 2026-06-28 15:12:28 +08:00
3 changed files with 42 additions and 41 deletions
+3 -8
View File
@@ -23,7 +23,7 @@
"ext-openssl": "*",
"ext-swoole": "*",
"ext-msgpack": "*",
"symfony/console": "^v8.0",
"symfony/console": "^v8.1.1",
"psr/log": "1.*",
"composer-runtime-api": "^2.0",
"psr/http-server-middleware": "^1.0.2",
@@ -32,17 +32,12 @@
"nikic/php-parser": "^v5.5.0",
"ext-inotify": "*",
"game-worker/kiri-pool": "^v1.0",
"psr/container": "^2.0",
"swiftmailer/swiftmailer": "^v6.3.0"
"psr/container": "^2.0"
},
"replace": {
"symfony/polyfill-apcu": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-mbstring": "*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php81": "*"
"symfony/polyfill-ctype": "*"
},
"autoload": {
"psr-4": {
+20 -23
View File
@@ -80,9 +80,9 @@ if (!function_exists('application')) {
if (!function_exists('task')) {
/**
* @param string $handler
* @param mixed $data
* @param int $dstWorkerId
* @param string $handler
* @param mixed $data
* @param int $dstWorkerId
* @param callable|null $finishFinishCallback
* @return void
* @throws Exception
@@ -98,9 +98,9 @@ if (!function_exists('task')) {
if (!function_exists('taskWait')) {
/**
* @param string $handler
* @param mixed $data
* @param float $timeout
* @param int $dstWorkerId
* @param mixed $data
* @param float $timeout
* @param int $dstWorkerId
* @return mixed
* @throws Exception
*/
@@ -166,8 +166,7 @@ if (!function_exists('isJson')) {
{
if (is_null($string))
return false;
return (str_starts_with($string, '{') && str_ends_with($string, '}'))
|| (str_ends_with($string, '[') && str_starts_with($string, ']'));
return (str_starts_with($string, '{') && str_ends_with($string, '}')) || (str_ends_with($string, '[') && str_starts_with($string, ']'));
}
}
@@ -176,7 +175,7 @@ if (!function_exists('instance')) {
/**
* @param $class
* @param $class
* @param array $constrict
* @param array $config
* @return null|object
@@ -195,7 +194,7 @@ if (!function_exists('call')) {
/**
* @param $handler
* @param $handler
* @param mixed ...$params
* @return mixed
* @throws
@@ -449,9 +448,9 @@ if (!function_exists('trim_blank')) {
/**
* 空白字符替换
* @param string $content 内容
* @param int $len 截取长度
* @param string $encode 编码
* @param bool $htmlTags
* @param int $len 截取长度
* @param string $encode 编码
* @param bool $htmlTags
* @return array|string|null
*/
function trim_blank(string $content, int $len = 0, string $encode = 'utf-8', bool $htmlTags = TRUE): array|string|null
@@ -745,8 +744,8 @@ if (!function_exists('on')) {
/**
* @param $name
* @param $callback
* @param $name
* @param $callback
* @param int $index
* @throws
*/
@@ -779,7 +778,7 @@ if (!function_exists('off')) {
if (!function_exists('process_name_set')) {
/**
* @param int $pid
* @param int $pid
* @param string|null $prefix
* @throws
*/
@@ -816,7 +815,7 @@ if (!function_exists('zero_full')) {
if (!function_exists('env')) {
/**
* @param $key
* @param $key
* @param null $default
* @return array|string|null
*/
@@ -835,7 +834,7 @@ if (!function_exists('env')) {
if (!function_exists('config')) {
/**
* @param $key
* @param $key
* @param null $default
* @return mixed
*/
@@ -850,7 +849,7 @@ if (!function_exists('config')) {
if (!function_exists('created')) {
/**
* @param $key
* @param $key
* @param array $construct
* @param array $config
* @return null|object
@@ -1029,9 +1028,7 @@ if (!function_exists('json_log')) {
];
$param['data'] = $data;
file_put_contents(storage('exception-' . date('Y-m-d') . '.log','exception'),
json_encode($param, JSON_UNESCAPED_UNICODE),
FILE_APPEND);
file_put_contents(storage('exception-' . date('Y-m-d') . '.log', 'exception'), json_encode($param, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
}
}
@@ -1039,7 +1036,7 @@ if (!function_exists('json_log')) {
if (!function_exists('map')) {
/**
* @param array $map
* @param array $map
* @param Closure $closure
* @return void
*/
+19 -10
View File
@@ -11,7 +11,7 @@ class Coordinator
const string WORKER_START = 'worker:start';
private bool $wait = true;
private bool $wait = false;
private ?Channel $channel = null;
@@ -22,12 +22,17 @@ class Coordinator
public function yield(): void
{
if (Coroutine::getCid() > 0) {
$this->channel = new Channel(1);
$this->channel->pop();
} else {
while ($this->wait) {
usleep(1000);
if ($this->channel instanceof Channel) {
$this->channel->pop();
}
return;
}
if ($this->wait === false) {
return;
}
while ($this->wait === true) {
usleep(1000);
}
}
@@ -37,8 +42,7 @@ class Coordinator
*/
public function wait(): void
{
$this->wait = true;
$this->channel = null;
Coroutine::getCid() > 0 ? $this->channel = new Channel(1) : $this->wait = true;
}
@@ -47,8 +51,13 @@ class Coordinator
*/
public function done(): void
{
$this->wait = false;
$this->channel?->push(true);
if (Coroutine::getCid() > 0) {
$this->channel?->push(true);
$this->channel->close();
$this->channel = null;
} else {
$this->wait = false;
}
}
}