Module on_server_idle.lua
Run tasks when the server is idle (spread work across globalsteps).
This module provides a simple mechanism to queue work and execute it only when the globalstep has spare time, helping avoid lag spikes.
Functions
-
# on_server_idle.wrap (task_fn) -
Wrap a function so that it runs when the server is idle.
Returns a new function which, when called, schedules the original function to run later with any given arguments.
Parameters
- task_fn function Function to wrap.
Returns
-
function
Wrapped function that schedules
fnon idle. -
# on_server_idle.run (task_fn) -
Schedule a task to run when the server is idle.
The provided function will be invoked in a later globalstep, depending on how much spare time is available.
Parameters
- task_fn
function
Function receiving
dtimeas the first argument.
- task_fn
function
Function receiving