libuv/docs/src/request.rst
Jameson Nash 612a8262b8 2025.01.15, Version 1.50.0 (Stable)
Changes since version 1.49.2:
 
 * ci: run macOS and iOS tests also on macOS 14 (Saúl Ibarra Corretgé)
 
 * unix,win: map ENOEXEC errno (Saúl Ibarra Corretgé)
 
 * test: skip multicast join test on ENOEXEC (Saúl Ibarra Corretgé)
 
 * ci: make sure the macOS firewall is disabled (Saúl Ibarra Corretgé)
 
 * darwin,test: squelch EBUSY error on multicast join (Saúl Ibarra Corretgé)
 
 * build: update minimum cmake to 3.10 (Ben Noordhuis)
 
 * kqueue: use EVFILT_USER for async if available (Jameson Nash)
 
 * unix,win: fix off-by-one in uv_wtf8_to_utf16() (Ben Noordhuis)
 
 * doc: add scala-native-loop to LINKS.md (Julian A Avar C)
 
 * unix: fix build breakage on haiku, openbsd, etc (Jeffrey H. Johnson)
 
 * kqueue: lower overhead in uv__io_check_fd (Andy Pan)
 
 * doc: move cjihrig back to active maintainers (cjihrig)
 
 * build(deps): bump actions/checkout from 3 to 4 (dependabot[bot])
 
 * unix,pipe: fix handling null buffer in uv_pipe_get{sock,peer}name (Saúl
   Ibarra Corretgé)
 
 * unix,win: harmonize buffer checking (Saúl Ibarra Corretgé)
 
 * unix,win: add support for detached threads (Juan José Arboleda)
 
 * src: add uv_thread_set/getname() methods (Santiago Gimeno)
 
 * build: fix qemu builds (Ben Noordhuis)
 
 * win: drop support for windows 8 (Ben Noordhuis)
 
 * linux: fix uv_cpu_info() arm cpu model detection (Ben Noordhuis)
 
 * linux: always use io_uring for epoll batching (Ben Noordhuis)
 
 * doc: clarify repeating timer behavior more (Ben Noordhuis)
 
 * unix,win: handle nbufs=0 in uv_udp_try_send (Ben Noordhuis)
 
 * win: use GetQueuedCompletionStatusEx directly (Saúl Ibarra Corretgé)
 
 * win: enable uv_thread_{get,set}name on MinGW (Saúl Ibarra Corretgé)
 
 * win: drop support for the legacy MinGW (Saúl Ibarra Corretgé)
 
 * win,fs: get (most) fstat when no permission (Jameson Nash)
 
 * win: plug uv_fs_event_start memory leak (amcgoogan)
 
 * test: address FreeBSD kernel bug causing NULL path in fsevents (Juan José
   Arboleda)
 
 * unix: refactor udp sendmsg code (Ben Noordhuis)
 
 * unix,win: add uv_udp_try_send2 (Ben Noordhuis)
 
 * test: fix flaky flaky udp_mmsg test (Juan José Arboleda)
 
 * build: enable fdsan in Android (Juan José Arboleda)
 
 * test: fix udp-multicast-join for FreeBSD (Juan José Arboleda)
 
 * win: fix leak processing fs event (Saúl Ibarra Corretgé)
 
 * src: set a default thread name for workers (Rafael Gonzaga)
 
 * misc: implement uv_getrusage_thread (Juan José Arboleda)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEYS8OrZQBYiN530QC8ow8jaM8A74FAmeH+OkACgkQ8ow8jaM8
 A75yQBAAiYL5OQM5nxSoEzOn9gBi3ssuvJX6549gytYRLQKyhHCeS43i+YFVeWbw
 OjQa59M2BuYz11YoHW5Vu/1ohU06CCugvwJ9QKSvEfsDcmtBIAJp4RO5XaGTtnlB
 k7PqJj/BrX+MyH8JzeioxILHuitlemwBy8fqrguxIqlO8XnT6H2lFtqwJsD/OvTj
 O5a2kjdyK0773LraOsv18XJBWWQ8dfebxZgVvYY2Vi461CpZKgq85uKYrBpQLkqK
 oVY9VrDRNkDQZGJgJiC3FqtNudw0W15y3vuEVoYTkaKbQzoAqx7HP3GyQaGc0186
 afGediLfb1SkVscbwVQMDB7UvJjJaGd9DNQoa7PorjtAn/l+tsrZpCGFGqwRmGIC
 w8s7/pmlyKTtsMgKV3WUmTvB6XDgWt70OK4viCpbf2COdoRWjTvdMkAq1FEv/E7B
 QWlzyqItuJ1Z556mnKy0ifCG5V/eW8HlaMhJARAsQDVeKzquTMvrvJNm8iKVKpFh
 8Y1OR+0nGc3l7Id9x8drKNWfGif11LraJXHUJmrfj9OLLHaE613krvXwahyogxap
 yTmtWDOcVS9z37xAh/JAd7eX7Aj157OhXy4ax55q2+9akp+jfTyvDRTgQHtAcq0J
 k21+HSnUwFVzyR8Ux8Vz2O+w7WXNOeatOK5UPZ+wKxtZ1Q7ylog=
 =pGW8
 -----END PGP SIGNATURE-----

Merge tag 'v1.50.0' into merge_1.50.0
2025-02-26 19:13:27 +00:00

136 lines
3.5 KiB
ReStructuredText

.. _request:
:c:type:`uv_req_t` --- Base request
===================================
`uv_req_t` is the base type for all libuv request types.
Structures are aligned so that any libuv request can be cast to `uv_req_t`.
All API functions defined here work with any request type.
Data types
----------
.. c:type:: uv_req_t
The base libuv request structure.
.. c:type:: uv_any_req
Union of all request types.
.. c:enum:: uv_req_type
The kind of the libuv request.
::
typedef enum {
UV_UNKNOWN_REQ = 0,
UV_REQ,
UV_CONNECT,
UV_WRITE,
UV_SHUTDOWN,
UV_UDP_SEND,
UV_FS,
UV_WORK,
UV_GETADDRINFO,
UV_GETNAMEINFO,
UV_REQ_TYPE_MAX,
} uv_req_type;
Public members
^^^^^^^^^^^^^^
.. c:member:: uv_loop_t* uv_req_t.loop
Loop that started this request and where completion will be reported.
Readonly.
.. versionadded:: 2.0.0
Moved from derived types (uv_connect_t, uv_fs_t, etc.) to uv_req_t.
.. c:member:: void* uv_req_t.data
Space for user-defined arbitrary data. libuv does not use this field.
.. c:member:: uv_req_type uv_req_t.type
The :c:enum:`uv_req_type`, indicating the type of the request. Readonly.
API
---
.. c:macro:: UV_REQ_TYPE_MAP(iter_macro)
Macro that expands to a series of invocations of `iter_macro` for
each of the request types. `iter_macro` is invoked with two
arguments: the name of the `uv_req_type` element without the `UV_`
prefix, and the name of the corresponding structure type without the
`uv_` prefix and `_t` suffix.
.. c:function:: int uv_cancel(uv_req_t* req)
Cancel a pending request. Fails if the request is executing or has finished
executing.
Returns 0 on success, or an error code < 0 on failure.
Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`,
:c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t`
requests is currently supported.
Cancelled requests have their callbacks invoked some time in the future.
It's **not** safe to free the memory associated with the request until the
callback is called.
Here is how cancellation is reported to the callback:
* A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`.
* A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`,
:c:type:`uv_getnameinfo_t` or :c:type:`uv_random_t` request has its
callback invoked with status == `UV_ECANCELED`.
.. c:function:: size_t uv_req_size(uv_req_type type)
Returns the size of the given request type. Useful for FFI binding writers
who don't want to know the structure layout.
.. c:function:: uv_loop_t* uv_req_get_loop(const uv_req_t* req)
Returns `req->loop`.
.. versionadded:: 2.0.0
.. c:function:: void* uv_req_get_data(const uv_req_t* req)
Returns `req->data`.
.. versionadded:: 1.19.0
.. c:function:: void uv_req_set_data(uv_req_t* req, void* data)
Sets `req->data` to `data`.
.. versionadded:: 1.19.0
.. c:function:: uv_req_type uv_req_get_type(const uv_req_t* req)
Returns `req->type`.
.. versionadded:: 1.19.0
.. c:function:: const char* uv_req_type_name(uv_req_type type)
Returns the name for the equivalent struct for a given request type,
e.g. `"connect"` (as in :c:type:`uv_connect_t`) for `UV_CONNECT`.
If no such request type exists, this returns `NULL`.
.. versionadded:: 1.19.0