Home Explore Blog CI



neovim

13th chunk of `runtime/doc/luvref.txt`
cd6409860cf70309b98107e9fd9d1a741aa862898e4b11e10000000100000fa6
 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| functions also apply.

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

    >lua
    local check = uv.new_check()
    check:start(function()
      print("After I/O polling")
    end)
<

uv.new_check()                                                  *uv.new_check()*

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

                Returns: `uv_check_t userdata`

uv.check_start({check}, {callback})                           *uv.check_start()*

                > method form `check:start(callback)`

                Parameters:
                - `check`: `uv_check_t userdata`
                - `callback`: `callable`

                Start the handle with the given callback.

                Returns: `0` or `fail`

uv.check_stop({check})                                         *uv.check_stop()*

                > method form `check:stop()`

                Parameters:
                - `check`: `uv_check_t userdata`

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

                Returns: `0` or `fail`

==============================================================================
`uv_idle_t` — Idle handle                              *luv-idle-handle* *uv_idle_t*

> |uv_handle_t| functions also apply.

Idle handles will run the given callback once per loop iteration, right before
the |uv_prepare_t| handles.

Note: The notable difference with prepare handles is that when there are
active idle handles, the loop will perform a zero timeout poll instead of
blocking for I/O.

WARNING: Despite the name, idle handles will get their callbacks called on
every loop iteration, not when the loop is actually "idle".

    >lua
    local idle = uv.new_idle()
    idle:start(function()
      print("Before I/O polling, no blocking")
    end)
<

uv.new_idle()                                                    *uv.new_idle()*

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

                Returns: `uv_idle_t userdata`

uv.idle_start({idle}, {callback})                              *uv.idle_start()*

                > method form `idle:start(callback)`

                Parameters:
                - `idle`: `uv_idle_t userdata`
                - `callback`: `callable`

                Start the handle with the given callback.

                Returns: `0` or `fail`

uv.idle_stop({check})                                           *uv.idle_stop()*

                > method form `idle:stop()`

                Parameters:
                - `idle`: `uv_idle_t userdata`

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

                Returns: `0` or `fail`

==============================================================================
`uv_async_t` — Async handle                          *luv-async-handle* *uv_async_t*

> |uv_handle_t| functions

Title: Libuv: Prepare, Check, and Idle Handles
Summary
This section describes prepare handles (`uv_prepare_t`), which execute a callback before I/O polling, and details the functions `uv.new_prepare()`, `uv.prepare_start()`, and `uv.prepare_stop()`. It then introduces check handles (`uv_check_t`), which execute a callback after I/O polling, including functions `uv.new_check()`, `uv.check_start()`, and `uv.check_stop()`. Finally, it covers idle handles (`uv_idle_t`), which execute a callback before prepare handles and cause the loop to perform a zero-timeout poll, with the associated functions `uv.new_idle()`, `uv.idle_start()`, and `uv.idle_stop()`.