Him188 4 роки тому
батько
коміт
6534b8177f

+ 3 - 6
backend/mirai-console/src/util/CoroutineScopeUtils.kt

@@ -68,16 +68,13 @@ internal class TimedTask(
         // `delay` always checks for cancellation
         lastChangedTime.loop { last ->
             val current = currentTimeMillis()
-            if (last == UNCHANGED) {
-                runIgnoreException<CancellationException> {
-                    delay(3.seconds) // accuracy not necessary
-                } ?: return@launch
-                return@loop
-            }
             if (current - last > intervalMillis) {
                 if (!lastChangedTime.compareAndSet(last, UNCHANGED)) return@loop
                 action()
             }
+            runIgnoreException<CancellationException> {
+                delay(3.seconds) // accuracy not necessary
+            } ?: return@launch
         }
     }
 }