Skip to content

Commit 864f236

Browse files
committed
fix AdaptiveBuilder
1 parent 84b1d0e commit 864f236

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Builders/Traits/AdaptiveTimerMethod.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ public function adaptiveTimerCreate(Closure $func, mixed ...$args): string
238238
// 移除旧定时器
239239
self::adaptiveTimerDelete($id);
240240
// 创建新定时器
241-
self::$timerIdMap[$id] = is_worker_version_5() and method_exists(Worker::$globalEvent, 'delay')
242-
? Worker::$globalEvent->delay(floatval($this->getTimerInitialInterval() / 1000), $callback, $args)
241+
self::$timerIdMap[$id] = (is_worker_version_5() and method_exists(Worker::$globalEvent, 'repeat'))
242+
? Worker::$globalEvent->repeat(floatval($this->getTimerInitialInterval() / 1000), $callback, $args)
243243
: Worker::$globalEvent->add(floatval($this->getTimerInterval() / 1000), EventInterface::EV_TIMER, $callback);
244244
}
245245
}
246246
};
247247
// 创建定时器
248-
self::$timerIdMap[$id] = is_worker_version_5() and method_exists(Worker::$globalEvent, 'delay')
249-
? Worker::$globalEvent->delay(floatval($this->getTimerInitialInterval() / 1000), $callback, $args)
248+
self::$timerIdMap[$id] = (is_worker_version_5() and method_exists(Worker::$globalEvent, 'repeat'))
249+
? Worker::$globalEvent->repeat(floatval($this->getTimerInitialInterval() / 1000), $callback, $args)
250250
: Worker::$globalEvent->add(floatval($this->getTimerInitialInterval() / 1000), EventInterface::EV_TIMER, $callback, $args);
251251
return $id;
252252
}
@@ -265,8 +265,8 @@ public function adaptiveTimerDelete(?string $id = null): void
265265
if ($id === null) {
266266
foreach(self::$timerIdMap as $id) {
267267
if (is_int($id)) {
268-
if (is_worker_version_5() and method_exists(Worker::$globalEvent, 'offDelay')) {
269-
Worker::$globalEvent->offDelay($id);
268+
if (is_worker_version_5() and method_exists(Worker::$globalEvent, 'offRepeat')) {
269+
Worker::$globalEvent->offRepeat($id);
270270
} else {
271271
Worker::$globalEvent->del($id, EventInterface::EV_TIMER);
272272
}
@@ -275,8 +275,8 @@ public function adaptiveTimerDelete(?string $id = null): void
275275
self::$timerIdMap = [];
276276
} else {
277277
if ($id = self::$timerIdMap[$id] ?? null) {
278-
if (is_worker_version_5() and method_exists(Worker::$globalEvent, 'offDelay')) {
279-
Worker::$globalEvent->offDelay($id);
278+
if (is_worker_version_5() and method_exists(Worker::$globalEvent, 'offRepeat')) {
279+
Worker::$globalEvent->offRepeat($id);
280280
} else {
281281
Worker::$globalEvent->del($id, EventInterface::EV_TIMER);
282282
}

0 commit comments

Comments
 (0)