Blame docs/src/async.rst

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