Mercurial
comparison third_party/libuv/docs/src/request.rst @ 160:948de3f54cea
[ThirdParty] Added libuv
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 14 Jan 2026 19:39:52 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 159:05cf9467a1c3 | 160:948de3f54cea |
|---|---|
| 1 | |
| 2 .. _request: | |
| 3 | |
| 4 :c:type:`uv_req_t` --- Base request | |
| 5 =================================== | |
| 6 | |
| 7 `uv_req_t` is the base type for all libuv request types. | |
| 8 | |
| 9 Structures are aligned so that any libuv request can be cast to `uv_req_t`. | |
| 10 All API functions defined here work with any request type. | |
| 11 | |
| 12 | |
| 13 Data types | |
| 14 ---------- | |
| 15 | |
| 16 .. c:type:: uv_req_t | |
| 17 | |
| 18 The base libuv request structure. | |
| 19 | |
| 20 .. c:type:: uv_any_req | |
| 21 | |
| 22 Union of all request types. | |
| 23 | |
| 24 .. c:enum:: uv_req_type | |
| 25 | |
| 26 The kind of the libuv request. | |
| 27 | |
| 28 :: | |
| 29 | |
| 30 typedef enum { | |
| 31 UV_UNKNOWN_REQ = 0, | |
| 32 UV_REQ, | |
| 33 UV_CONNECT, | |
| 34 UV_WRITE, | |
| 35 UV_SHUTDOWN, | |
| 36 UV_UDP_SEND, | |
| 37 UV_FS, | |
| 38 UV_WORK, | |
| 39 UV_GETADDRINFO, | |
| 40 UV_GETNAMEINFO, | |
| 41 UV_REQ_TYPE_MAX, | |
| 42 } uv_req_type; | |
| 43 | |
| 44 | |
| 45 Public members | |
| 46 ^^^^^^^^^^^^^^ | |
| 47 | |
| 48 .. c:member:: void* uv_req_t.data | |
| 49 | |
| 50 Space for user-defined arbitrary data. libuv does not use this field. | |
| 51 | |
| 52 .. c:member:: uv_req_type uv_req_t.type | |
| 53 | |
| 54 The :c:enum:`uv_req_type`, indicating the type of the request. Readonly. | |
| 55 | |
| 56 | |
| 57 API | |
| 58 --- | |
| 59 | |
| 60 .. c:macro:: UV_REQ_TYPE_MAP(iter_macro) | |
| 61 | |
| 62 Macro that expands to a series of invocations of `iter_macro` for | |
| 63 each of the request types. `iter_macro` is invoked with two | |
| 64 arguments: the name of the `uv_req_type` element without the `UV_` | |
| 65 prefix, and the name of the corresponding structure type without the | |
| 66 `uv_` prefix and `_t` suffix. | |
| 67 | |
| 68 .. c:function:: int uv_cancel(uv_req_t* req) | |
| 69 | |
| 70 Cancel a pending request. Fails if the request is executing or has finished | |
| 71 executing. | |
| 72 | |
| 73 Returns 0 on success, or an error code < 0 on failure. | |
| 74 | |
| 75 Only cancellation of :c:type:`uv_fs_t`, :c:type:`uv_getaddrinfo_t`, | |
| 76 :c:type:`uv_getnameinfo_t`, :c:type:`uv_random_t` and :c:type:`uv_work_t` | |
| 77 requests is currently supported. | |
| 78 | |
| 79 Cancelled requests have their callbacks invoked some time in the future. | |
| 80 It's **not** safe to free the memory associated with the request until the | |
| 81 callback is called. | |
| 82 | |
| 83 Here is how cancellation is reported to the callback: | |
| 84 | |
| 85 * A :c:type:`uv_fs_t` request has its req->result field set to `UV_ECANCELED`. | |
| 86 | |
| 87 * A :c:type:`uv_work_t`, :c:type:`uv_getaddrinfo_t`, | |
| 88 :c:type:`uv_getnameinfo_t` or :c:type:`uv_random_t` request has its | |
| 89 callback invoked with status == `UV_ECANCELED`. | |
| 90 | |
| 91 .. c:function:: size_t uv_req_size(uv_req_type type) | |
| 92 | |
| 93 Returns the size of the given request type. Useful for FFI binding writers | |
| 94 who don't want to know the structure layout. | |
| 95 | |
| 96 .. c:function:: void* uv_req_get_data(const uv_req_t* req) | |
| 97 | |
| 98 Returns `req->data`. | |
| 99 | |
| 100 .. versionadded:: 1.19.0 | |
| 101 | |
| 102 .. c:function:: void uv_req_set_data(uv_req_t* req, void* data) | |
| 103 | |
| 104 Sets `req->data` to `data`. | |
| 105 | |
| 106 .. versionadded:: 1.19.0 | |
| 107 | |
| 108 .. c:function:: uv_req_type uv_req_get_type(const uv_req_t* req) | |
| 109 | |
| 110 Returns `req->type`. | |
| 111 | |
| 112 .. versionadded:: 1.19.0 | |
| 113 | |
| 114 .. c:function:: const char* uv_req_type_name(uv_req_type type) | |
| 115 | |
| 116 Returns the name for the equivalent struct for a given request type, | |
| 117 e.g. `"connect"` (as in :c:type:`uv_connect_t`) for `UV_CONNECT`. | |
| 118 | |
| 119 If no such request type exists, this returns `NULL`. | |
| 120 | |
| 121 .. versionadded:: 1.19.0 |