nvim_runtime_lua

uv.uv_timer_t

uv_timer_t - Timer handle

[uv_handle_t][] functions also apply.

Timer handles are used to schedule callbacks to be called in the future.

Methods6

function uv_timer_t.start(timeout: integer, repeat_: integer, callback: fun() -> nil) -> (success 0 | nil, err nil | string, err_name uv.error_name | nil)

Start the timer. timeout and repeat are in milliseconds.

If timeout is zero, the callback fires on the next event loop iteration. If repeat is non-zero, the callback fires first after timeout milliseconds and then repeatedly after repeat milliseconds.

function uv_timer_t.stop() -> (success 0 | nil, err nil | string, err_name uv.error_name | nil)

Stop the timer, the callback will not be called anymore.

function uv_timer_t.again() -> (success 0 | nil, err nil | string, err_name uv.error_name | nil)

Stop the timer, and if it is repeating restart it using the repeat value as the timeout. If the timer has never been started before it raises EINVAL.

function uv_timer_t.set_repeat(repeat_: integer)

Set the repeat interval value in milliseconds. The timer will be scheduled to run on the given interval, regardless of the callback execution duration, and will follow normal timer semantics in the case of a time-slice overrun.

For example, if a 50 ms repeating timer first runs for 17 ms, it will be scheduled to run again 33 ms later. If other tasks consume more than the 33 ms following the first timer callback, then the callback will run as soon as possible.

function uv_timer_t.get_repeat() -> repeat_ integer

Get the timer repeat value.

function uv_timer_t.get_due_in() -> due_in integer

Get the timer due value or 0 if it has expired. The time is relative to uv.now().