Home Explore Blog CI



neovim

5th chunk of `runtime/doc/luvref.txt`
f98680b1ac1a518268f4c56a0171b4bbdd59f2b1a5144dda0000000100000fa9

- `EFTYPE`: inappropriate file type or format.
- `EILSEQ`: illegal byte sequence.
- `ESOCKTNOSUPPORT`: socket type not supported.

==============================================================================
VERSION CHECKING                                          *luv-version-checking*

uv.version()                                                      *uv.version()*

                Returns the libuv version packed into a single integer. 8 bits
                are used for each component, with the patch number stored in
                the 8 least significant bits. For example, this would be
                0x010203 in libuv 1.2.3.

                Returns: `integer`

uv.version_string()                                        *uv.version_string()*

                Returns the libuv version number as a string. For example,
                this would be "1.2.3" in libuv 1.2.3. For non-release
                versions, the version suffix is included.

                Returns: `string`

==============================================================================
`uv_loop_t` — Event loop                                *luv-event-loop* *uv_loop_t*

The event loop is the central part of libuv's functionality. It takes care of
polling for I/O and scheduling callbacks to be run based on different sources
of events.

In luv, there is an implicit uv loop for every Lua state that loads the
library. You can use this library in an multi-threaded environment as long as
each thread has it's own Lua state with its corresponding own uv loop. This
loop is not directly exposed to users in the Lua module.

uv.loop_close()                                                *uv.loop_close()*

                Closes all internal loop resources. In normal execution, the
                loop will automatically be closed when it is garbage collected
                by Lua, so it is not necessary to explicitly call
                `loop_close()`. Call this function only after the loop has
                finished executing and all open handles and requests have been
                closed, or it will return `EBUSY`.

                Returns: `0` or `fail`

uv.run([{mode}])                                                      *uv.run()*

                Parameters:
                - `mode`: `string` or `nil` (default: `"default"`)

                This function runs the event loop. It will act differently
                depending on the specified mode:

                  - `"default"`: Runs the event loop until there are no more
                    active and referenced handles or requests. Returns `true`
                    if |uv.stop()| was called and there are still active
                    handles or requests. Returns `false` in all other cases.

                  - `"once"`: Poll for I/O once. Note that this function
                    blocks if there are no pending callbacks. Returns `false`
                    when done (no active handles or requests left), or `true`
                    if more callbacks are expected (meaning you should run the
                    event loop again sometime in the future).

                  - `"nowait"`: Poll for I/O once but don't block if there are
                    no pending callbacks. Returns `false` if done (no active
                    handles or requests left), or `true` if more callbacks are
                    expected (meaning you should run the event loop again
                    sometime in the future).

                Returns: `boolean` or `fail`

                Note: Luvit will implicitly call `uv.run()` after loading user
                code, but if you use the luv bindings directly, you need to
                call this after registering your initial set of event
                callbacks to start the event loop.

uv.loop_configure({option}, {...})                         *uv.loop_configure()*

                Parameters:
                - `option`: `string`
                - `...`: depends

Title: Version Checking and Event Loop Management
Summary
This section covers libuv version checking functions and event loop management in luv. The version checking functions include `uv.version()` which returns the libuv version as a packed integer, and `uv.version_string()` which returns the version as a string. The event loop section describes the `uv_loop_t` object and explains that each Lua state has an implicit uv loop. It also details `uv.loop_close()` for closing loop resources, `uv.run()` for running the event loop in different modes (default, once, nowait), and `uv.loop_configure()` for loop configuration.