|
VoltMod
C++23 framework for CS2 server plugins
|
One-shot delays and repeating timers, run on the game thread. More...
#include <Scheduler.hpp>
Public Member Functions | |
| Scheduler ()=default | |
| Subscription | Delay (int64_t delayMs, std::function< void()> callback) |
| Subscription | Repeat (int64_t intervalMs, std::function< void()> callback) |
| Subscription | NextTick (std::function< void()> callback) |
| Subscription | EveryFrame (std::function< void()> callback) |
| Subscription | EveryFrame (std::function< void(float seconds)> callback, float maxSeconds=MaxFrameSeconds) |
| void | OnGameFrame () |
Static Public Attributes | |
| static constexpr float | MaxFrameSeconds = 0.1f |
One-shot delays and repeating timers, run on the game thread.
Dropping a registration's Subscription cancels its timer, one-shots included, so a callback never outlives the state it captured.
Definition at line 17 of file Scheduler.hpp.
|
default |
|
nodiscard |
Run callback once after delayMs milliseconds.
Definition at line 22 of file Scheduler.cpp.
Referenced by NextTick(), and VoltMod::TimerOn().
|
nodiscard |
Run callback every game frame.
Definition at line 37 of file Scheduler.cpp.
Referenced by EveryFrame().
|
nodiscard |
Run callback every game frame with the seconds since its previous call, or since this call for the first. Capped at maxSeconds, so a server hitch does not jump anything moving across the map.
Definition at line 43 of file Scheduler.cpp.
References EveryFrame().
|
nodiscard |
Run callback on the very next game frame.
Definition at line 32 of file Scheduler.cpp.
References Delay().
| void VoltMod::Scheduler::OnGameFrame | ( | ) |
Called every frame by the runtime.
Definition at line 59 of file Scheduler.cpp.
|
nodiscard |
Run callback every intervalMs milliseconds.
Definition at line 27 of file Scheduler.cpp.
|
staticconstexpr |
The longest frame step EveryFrame reports, in seconds.
Definition at line 35 of file Scheduler.hpp.