Blame docs/src/async.rst

Packit Service 7c31a4
Packit Service 7c31a4
.. _async:
Packit Service 7c31a4
Packit Service 7c31a4
:c:type:`uv_async_t` --- Async handle
Packit Service 7c31a4
=====================================
Packit Service 7c31a4
Packit Service 7c31a4
Async handles allow the user to "wakeup" the event loop and get a callback
Packit Service 7c31a4
called from another thread.
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Data types
Packit Service 7c31a4
----------
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: uv_async_t
Packit Service 7c31a4
Packit Service 7c31a4
    Async handle type.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:type:: void (*uv_async_cb)(uv_async_t* handle)
Packit Service 7c31a4
Packit Service 7c31a4
    Type definition for callback passed to :c:func:`uv_async_init`.
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
Public members
Packit Service 7c31a4
^^^^^^^^^^^^^^
Packit Service 7c31a4
Packit Service 7c31a4
N/A
Packit Service 7c31a4
Packit Service 7c31a4
.. seealso:: The :c:type:`uv_handle_t` members also apply.
Packit Service 7c31a4
Packit Service 7c31a4
Packit Service 7c31a4
API
Packit Service 7c31a4
---
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb)
Packit Service 7c31a4
Packit Service 7c31a4
    Initialize the handle. A NULL callback is allowed.
Packit Service 7c31a4
Packit Service 7c31a4
    :returns: 0 on success, or an error code < 0 on failure.
Packit Service 7c31a4
Packit Service 7c31a4
    .. note::
Packit Service 7c31a4
        Unlike other handle initialization  functions, it immediately starts the handle.
Packit Service 7c31a4
Packit Service 7c31a4
.. c:function:: int uv_async_send(uv_async_t* async)
Packit Service 7c31a4
Packit Service 7c31a4
    Wake up the event loop and call the async handle's callback.
Packit Service 7c31a4
Packit Service 7c31a4
    :returns: 0 on success, or an error code < 0 on failure.
Packit Service 7c31a4
Packit Service 7c31a4
    .. note::
Packit Service 7c31a4
        It's safe to call this function from any thread. The callback will be called on the
Packit Service 7c31a4
        loop thread.
Packit Service 7c31a4
Packit Service 7c31a4
    .. note::
Packit Service 7c31a4
        :c:func:`uv_async_send` is `async-signal-safe <http://man7.org/linux/man-pages/man7/signal-safety.7.html>`_.
Packit Service 7c31a4
        It's safe to call this function from a signal handler.
Packit Service 7c31a4
Packit Service 7c31a4
    .. warning::
Packit Service 7c31a4
        libuv will coalesce calls to :c:func:`uv_async_send`, that is, not every call to it will
Packit Service 7c31a4
        yield an execution of the callback. For example: if :c:func:`uv_async_send` is called 5
Packit Service 7c31a4
        times in a row before the callback is called, the callback will only be called once. If
Packit Service 7c31a4
        :c:func:`uv_async_send` is called again after the callback was called, it will be called
Packit Service 7c31a4
        again.
Packit Service 7c31a4
Packit Service 7c31a4
.. seealso::
Packit Service 7c31a4
    The :c:type:`uv_handle_t` API functions also apply.