Home Explore Blog CI



neovim

12th chunk of `runtime/doc/luvref.txt`
faf31023078dd1da3c641cffb0909b6de2a9515a9e42764a0000000100000fa5
 repeatedly after
                `repeat` milliseconds.

                Returns: `0` or `fail`

uv.timer_stop({timer})                                         *uv.timer_stop()*

                > method form `timer:stop()`

                Parameters:
                - `timer`: `uv_timer_t userdata`

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

                Returns: `0` or `fail`

uv.timer_again({timer})                                       *uv.timer_again()*

                > method form `timer:again()`

                Parameters:
                - `timer`: `uv_timer_t userdata`

                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`.

                Returns: `0` or `fail`

uv.timer_set_repeat({timer}, {repeat})                   *uv.timer_set_repeat()*

                > method form `timer:set_repeat(repeat)`

                Parameters:
                - `timer`: `uv_timer_t userdata`
                - `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.

                Returns: Nothing.

uv.timer_get_repeat({timer})                             *uv.timer_get_repeat()*

                > method form `timer:get_repeat()`

                Parameters:
                - `timer`: `uv_timer_t userdata`

                Get the timer repeat value.

                Returns: `integer`

uv.timer_get_due_in({timer})                             *uv.timer_get_due_in()*

                > method form `timer:get_due_in()`

                Parameters:
                - `timer`: `uv_timer_t userdata`

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

                Returns: `integer`

                Note: New in libuv version 1.40.0.

==============================================================================
`uv_prepare_t` — Prepare handle                  *luv-prepare-handle* *uv_prepare_t*

> |uv_handle_t| functions also apply.

Prepare handles will run the given callback once per loop iteration, right
before polling for I/O.

    >lua
    local prepare = uv.new_prepare()
    prepare:start(function()
      print("Before I/O polling")
    end)
<

uv.new_prepare()                                              *uv.new_prepare()*

                Creates and initializes a new |uv_prepare_t|. Returns the Lua
                userdata wrapping it.

                Returns: `uv_prepare_t userdata`

uv.prepare_start({prepare}, {callback})                     *uv.prepare_start()*

                > method form `prepare:start(callback)`

                Parameters:
                - `prepare`: `uv_prepare_t userdata`
                - `callback`: `callable`

                Start the handle with the given callback.

                Returns: `0` or `fail`

uv.prepare_stop({prepare})                                   *uv.prepare_stop()*

                > method form `prepare:stop()`

                Parameters:
                - `prepare`: `uv_prepare_t userdata`

                Stop the handle, the callback will no longer be called.

                Returns: `0` or `fail`

==============================================================================
`uv_check_t` — Check handle                          *luv-check-handle* *uv_check_t*

> |uv_handle_t|

Title: Libuv: Timer Functions (cont.), Prepare Handles, and Check Handles
Summary
This section details additional timer functions: `uv.timer_set_repeat()`, which sets the repeat interval; `uv.timer_get_repeat()`, which retrieves the repeat value; and `uv.timer_get_due_in()`, which returns the time until the timer expires. It then introduces prepare handles (`uv_prepare_t`), which execute a callback before I/O polling, and describes the functions `uv.new_prepare()`, `uv.prepare_start()`, and `uv.prepare_stop()`. Finally, it mentions check handles (`uv_check_t`).