Lines Matching defs:handle
45 int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
52 uv__handle_init(loop, (uv_handle_t*)handle, UV_ASYNC);
53 handle->async_cb = async_cb;
54 handle->pending = 0;
56 QUEUE_INSERT_TAIL(&loop->async_handles, &handle->queue);
57 uv__handle_start(handle);
63 int uv_async_send(uv_async_t* handle) {
65 if (ACCESS_ONCE(int, handle->pending) != 0)
68 /* Tell the other thread we're busy with the handle. */
69 if (cmpxchgi(&handle->pending, 0, 1) != 0)
73 uv__async_send(handle->loop);
76 if (cmpxchgi(&handle->pending, 1, 2) != 1)
84 static int uv__async_spin(uv_async_t* handle) {
93 /* rc=0 -- handle is not pending.
94 * rc=1 -- handle is pending, other thread is still working with it.
95 * rc=2 -- handle is pending, other thread is done.
97 rc = cmpxchgi(&handle->pending, 2, 0);
102 /* Other thread is busy with this handle, spin until it's done. */
115 void uv__async_close(uv_async_t* handle) {
116 uv__async_spin(handle);
117 QUEUE_REMOVE(&handle->queue);
118 uv__handle_stop(handle);