uv_async_t — Async handle¶
Async handles allow the user to “wakeup” the event loop and get a callback called from another thread.
Async handle type.
uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb)¶
Initialize the handle. A NULL callback is allowed.
Unlike other handle initialization functions, it immediately starts the handle.
Wakeup the event loop and call the async handle’s callback.
It’s safe to call this function from any thread. The callback will be called on the loop thread.
libuv will coalesce calls to
uv_async_send(), that is, not every call to it will yield an execution of the callback. For example: if
uv_async_send()is called 5 times in a row before the callback is called, the callback will only be called once. If
uv_async_send()is called again after the callback was called, it will be called again.
uv_handle_t API functions also apply.