格式整理

This commit is contained in:
EmsiaetKadosh
2025-03-16 14:18:05 +08:00
parent a1d0f11032
commit c344588924
23 changed files with 467 additions and 257 deletions
+12 -3
View File
@@ -10,12 +10,15 @@ class TaskScheduler;
class Task final : public AnywhereEditable<Task> {
friend class TaskScheduler;
#ifndef __CARLBEKS_DEBUG__
QWORD triggerInterval = 0, nextExecuteTime = 0, lastExecuteTime = 0;
#endif
public:
Function<void(Task& self)> func;
explicit Task(const Function<void(Task& self)>& func) : func(func) {}
explicit Task(Function<void(Task& self)>&& func) : func(std::move(func)) {}
Task(const Function<void(Task& self)>& func) : func(func) {}
Task(Function<void(Task& self)>&& func) : func(std::move(func)) {}
void schedulePop(const bool pop) noexcept { reserved[0] = pop; }
[[nodiscard]] bool scheduledPop() const noexcept { return reserved[0]; }
@@ -23,6 +26,12 @@ public:
schedulePop(true);
Success();
}
#ifndef __CARLBEKS_DEBUG__
Task& every(QWORD tick);
Task& after(QWORD tick);
Task& until(QWORD tick);
Task& forever();
#endif
};
class TaskScheduler {
@@ -34,7 +43,7 @@ public:
task.func(task);
if (task.scheduledPop()) {
task.schedulePop(false);
tasks.pop(&task);
tasks.pop(&task); // pop后删除了内存,迭代器的current失效
}
}
}