Skip to content

Commit f0d4091

Browse files
author
tourze-ci
committed
refactor(symfony-aop-bundle): 调整 ContextService 类中的 Workerman 逻辑
1 parent 44b87a7 commit f0d4091

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Service/ContextService.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ public function isCoroutineRuntime(): bool
3535
return false;
3636
}
3737

38-
/**
39-
* 判断是否运行在Workerman环境中
40-
*/
41-
public function isWorkerman(): bool
42-
{
43-
return class_exists(\Workerman\Worker::class) && \Workerman\Worker::$pidFile !== '';
44-
}
45-
4638
public function isSwoole(): bool
4739
{
4840
return class_exists(\Swoole\Coroutine::class) && \Swoole\Coroutine::getCid() > 0;
@@ -75,7 +67,10 @@ public function defer(callable $callback): void
7567
return;
7668
}
7769

78-
if ($this->isWorkerman()) {
70+
if (class_exists(\Workerman\Worker::class)
71+
&& \Workerman\Worker::$pidFile !== ''
72+
&& class_exists(\Workerman\Timer::class)
73+
) {
7974
\Workerman\Timer::add(0.001, $callback, persistent: false);
8075
return;
8176
}

0 commit comments

Comments
 (0)