Qu

run_for

Builtin index · Concurrency

result = run_for(duration)

Input: duration · Output: result

What it is

Drives every registered every/after/at timer across a simulated virtual timeline, not a real wall-clock sleep. duration (number — seconds, same convention as every/after/at's own interval arguments) is how far along that virtual timeline to advance. Timers interleave by scheduled fire time, the way a real event loop would. Requires at least one timer to already be registered, or it errors.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = run_for(duration)
duration numbernot documented yet
result number
Returns an integer: the total number of timer firings that occurred while advancing.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

count = 0
every 1 s do
    count = count + 1
end
run_for(5 s)
print("fired {count} times")
output
· run_for(5s): 5 timer firing(s) across 1 registered timer(s)
fired 5 times

from specialized

How it works

run_for(duration) (seconds — same convention as every/ after/at, e.g. run_for(500 ms) or run_for(0.5)) drives every registered timer across a simulated virtual timeline, not a real wall-clock sleep — a batch script asking to "simulate 10s of a control loop" should not actually block for 10 real seconds (and a real-time sleep would make test suites slow or flaky). Timers interleave by scheduled fire time (not "run timer A to completion, then timer B"), the way a real event loop would.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.