Home Explore Blog CI



neovim

46th chunk of `runtime/doc/luvref.txt`
ab0f63f7affaf026e80ee0fa0f44a2ed7060dd8ecf5be81d0000000100000fa0
 returned by a successful
                |uv.fs_opendir()| call.

                Returns (sync version): `boolean` or `fail`

                Returns (async version): `uv_fs_t userdata`

uv.fs_statfs({path} [, {callback}])                             *uv.fs_statfs()*

                Parameters:
                - `path`: `string`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
                  - `err`: `nil` or `string`
                  - `table` or `nil` (see below)

                Equivalent to `statfs(2)`.

                Returns `table` or `nil`
                - `type` : `integer`
                - `bsize` : `integer`
                - `blocks` : `integer`
                - `bfree` : `integer`
                - `bavail` : `integer`
                - `files` : `integer`
                - `ffree` : `integer`

==============================================================================
THREAD POOL WORK SCHEDULING                    *luv-thread-pool-work-scheduling*

Libuv provides a threadpool which can be used to run user code and get
notified in the loop thread. This threadpool is internally used to run all
file system operations, as well as `getaddrinfo` and `getnameinfo` requests.

    >lua
    local function work_callback(a, b)
      return a + b
    end

    local function after_work_callback(c)
      print("The result is: " .. c)
    end

    local work = uv.new_work(work_callback, after_work_callback)

    work:queue(1, 2)

    -- output: "The result is: 3"
<

uv.new_work({work_callback}, {after_work_callback})              *uv.new_work()*

                Parameters:
                - `work_callback`: `function` or `string`
                  - `...`: `threadargs` passed to/from
                    `uv.queue_work(work_ctx, ...)`
                - `after_work_callback`: `function`
                  - `...`: `threadargs` returned from `work_callback`

                Creates and initializes a new `luv_work_ctx_t` (not
                `uv_work_t`).
                `work_callback` is a Lua function or a string containing Lua
                code or bytecode dumped from a function. Returns the Lua
                userdata wrapping it.

                Returns: `luv_work_ctx_t userdata`

uv.queue_work({work_ctx}, {...})                               *uv.queue_work()*

                > method form `work_ctx:queue(...)`

                Parameters:
                - `work_ctx`: `luv_work_ctx_t userdata`
                - `...`: `threadargs`

                Queues a work request which will run `work_callback` in a new
                Lua state in a thread from the threadpool with any additional
                arguments from `...`. Values returned from `work_callback` are
                passed to `after_work_callback`, which is called in the main
                loop thread.

                Returns: `boolean` or `fail`

==============================================================================
DNS UTILITY FUNCTIONS                                *luv-dns-utility-functions*

uv.getaddrinfo({host}, {service} [, {hints} [, {callback}]])  *uv.getaddrinfo()*

                Parameters:
                - `host`: `string` or `nil`
                - `service`: `string` or `nil`
                - `hints`: `table` or `nil`
                  - `family`: `string` or `integer` or `nil`
                  - `socktype`: `string` or `integer` or `nil`
                  - `protocol`: `string` or `integer` or `nil`
                  - `addrconfig`: `boolean` or `nil`
                  - `v4mapped`: `boolean` or `nil`
                  - `all`: `boolean` or `nil`
                  - `numerichost`: `boolean` or `nil`
                  - `passive`: `boolean` or `nil`
                  - `numericserv`: `boolean` or `nil`
                  - `canonname`: `boolean` or `nil`
                - `callback`: `callable` (async version) or `nil` (sync
                  version)
            

Title: File System Statistics, Thread Pool Work Scheduling, and DNS Utility Functions
Summary
This section describes the `uv.fs_statfs` function (retrieves file system statistics), the thread pool work scheduling mechanism in Libuv, including `uv.new_work` (creates a work context) and `uv.queue_work` (queues a work request to be executed in a thread pool). It also covers DNS utility functions, specifically `uv.getaddrinfo`, which performs address resolution.