Home Explore Blog CI



neovim

8th chunk of `runtime/doc/luvref.txt`
c64943bb9d601e50f75643888edc96d68045a2c4971610380000000100000fa6
               end)
<

==============================================================================
`uv_req_t` — Base request                              *luv-base-request* *uv_req_t*

`uv_req_t` is the base type for all libuv request types.

uv.cancel({req})                                                   *uv.cancel()*

                > method form `req:cancel()`

                Parameters:
                - `req`: `userdata` for sub-type of |uv_req_t|

                Cancel a pending request. Fails if the request is executing or
                has finished executing. Only cancellation of |uv_fs_t|,
                `uv_getaddrinfo_t`, `uv_getnameinfo_t` and `uv_work_t`
                requests is currently supported.

                Returns: `0` or `fail`

uv.req_get_type({req})                                       *uv.req_get_type()*

                > method form `req:get_type()`

                Parameters:
                - `req`: `userdata` for sub-type of |uv_req_t|

                Returns the name of the struct for a given request (e.g.
                `"fs"` for |uv_fs_t|) and the libuv enum integer for the
                request's type (`uv_req_type`).

                Returns: `string, integer`

==============================================================================
`uv_handle_t` — Base handle                          *luv-base-handle* *uv_handle_t*

`uv_handle_t` is the base type for all libuv handle types. All API functions
defined here work with any handle type.

uv.is_active({handle})                                          *uv.is_active()*

                > method form `handle:is_active()`

                Parameters:
                - `handle`: `userdata` for sub-type of |uv_handle_t|

                Returns `true` if the handle is active, `false` if it's
                inactive. What "active” means depends on the type of handle:

                  - A |uv_async_t| handle is always active and cannot be
                    deactivated, except by closing it with |uv.close()|.

                  - A |uv_pipe_t|, |uv_tcp_t|, |uv_udp_t|, etc.
                    handle - basically any handle that deals with I/O - is
                    active when it is doing something that involves I/O, like
                    reading, writing, connecting, accepting new connections,
                    etc.

                  - A |uv_check_t|, |uv_idle_t|, |uv_timer_t|,
                    etc. handle is active when it has been started with a call
                    to |uv.check_start()|, |uv.idle_start()|,
                    |uv.timer_start()| etc. until it has been stopped with a
                    call to its respective stop function.

                Returns: `boolean` or `fail`

uv.is_closing({handle})                                        *uv.is_closing()*

                > method form `handle:is_closing()`

                Parameters:
                - `handle`: `userdata` for sub-type of |uv_handle_t|

                Returns `true` if the handle is closing or closed, `false`
                otherwise.

                Returns: `boolean` or `fail`

                Note: This function should only be used between the
                initialization of the handle and the arrival of the close
                callback.

uv.close({handle} [, {callback}])                                   *uv.close()*

                > method form `handle:close([callback])`

                Parameters:
                - `handle`: `userdata` for sub-type of |uv_handle_t|
                - `callback`: `callable` or `nil`

                Request handle to be closed. `callback` will be called
                asynchronously after this call. This MUST be called on each
                handle before memory is released.

                Handles that wrap file descriptors are closed immediately but
                `callback` will still be deferred to the next iteration of the
                event loop. It gives you a chance

Title: Libuv Request and Handle Management: Cancelling Requests, Checking Handle Status, and Closing Handles
Summary
This section outlines functions for managing libuv requests and handles. It describes `uv.cancel()` for cancelling pending requests, `uv.req_get_type()` for getting request type information. It also covers handle management functions, including `uv.is_active()` to check if a handle is active, `uv.is_closing()` to check if a handle is closing, and `uv.close()` to request a handle to be closed with an optional callback.