Rizin
unix-like reverse engineering framework and cli tools
async.c File Reference
#include <assert.h>
#include "uv.h"
#include "internal.h"
#include "atomicops-inl.h"
#include "handle-inl.h"
#include "req-inl.h"

Go to the source code of this file.

Functions

void uv_async_endgame (uv_loop_t *loop, uv_async_t *handle)
 
int uv_async_init (uv_loop_t *loop, uv_async_t *handle, uv_async_cb async_cb)
 
void uv_async_close (uv_loop_t *loop, uv_async_t *handle)
 
int uv_async_send (uv_async_t *handle)
 
void uv_process_async_wakeup_req (uv_loop_t *loop, uv_async_t *handle, uv_req_t *req)
 

Function Documentation

◆ uv_async_close()

void uv_async_close ( uv_loop_t loop,
uv_async_t handle 
)

Definition at line 57 of file async.c.

57  {
58  if (!((uv_async_t*)handle)->async_sent) {
60  }
61 
63 }
static mcore_handle handle
Definition: asm_mcore.c:8
static INLINE void uv_want_endgame(uv_loop_t *loop, uv_handle_t *handle)
Definition: handle-inl.h:88
#define uv__handle_closing(handle)
Definition: handle-inl.h:63
Definition: uv.h:844
uv_loop_t * loop
Definition: main.c:7

References handle, loop, uv__handle_closing, and uv_want_endgame().

Referenced by uv_close().

◆ uv_async_endgame()

void uv_async_endgame ( uv_loop_t loop,
uv_async_t handle 
)

Definition at line 31 of file async.c.

31  {
32  if (handle->flags & UV_HANDLE_CLOSING &&
33  !handle->async_sent) {
34  assert(!(handle->flags & UV_HANDLE_CLOSED));
36  }
37 }
#define uv__handle_close(handle)
Definition: handle-inl.h:76
assert(limit<=UINT32_MAX/2)
@ UV_HANDLE_CLOSING
Definition: uv-common.h:74
@ UV_HANDLE_CLOSED
Definition: uv-common.h:75

References assert(), handle, uv__handle_close, UV_HANDLE_CLOSED, and UV_HANDLE_CLOSING.

Referenced by uv_process_endgames().

◆ uv_async_init()

int uv_async_init ( uv_loop_t loop,
uv_async_t handle,
uv_async_cb  async_cb 
)

Definition at line 40 of file async.c.

40  {
41  uv_req_t* req;
42 
43  uv__handle_init(loop, (uv_handle_t*) handle, UV_ASYNC);
44  handle->async_sent = 0;
45  handle->async_cb = async_cb;
46 
47  req = &handle->async_req;
48  UV_REQ_INIT(req, UV_WAKEUP);
49  req->data = handle;
50 
52 
53  return 0;
54 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition: sflib.h:128
Definition: uv.h:407
#define UV_REQ_INIT(req, typ)
Definition: uv-common.h:322
#define uv__handle_init(loop_, h, type_)
Definition: uv-common.h:301
#define uv__handle_start(h)
Definition: uv-common.h:258

References err, handle, loop, QUEUE_INSERT_TAIL, req, uv__async_start(), uv__handle_init, uv__handle_start, and UV_REQ_INIT.

Referenced by main(), and uv_loop_init().

◆ uv_async_send()

int uv_async_send ( uv_async_t handle)

Definition at line 66 of file async.c.

66  {
67  uv_loop_t* loop = handle->loop;
68 
69  if (handle->type != UV_ASYNC) {
70  /* Can't set errno because that's not thread-safe. */
71  return -1;
72  }
73 
74  /* The user should make sure never to call uv_async_send to a closing or
75  * closed handle. */
76  assert(!(handle->flags & UV_HANDLE_CLOSING));
77 
78  if (!uv__atomic_exchange_set(&handle->async_sent)) {
79  POST_COMPLETION_FOR_REQ(loop, &handle->async_req);
80  }
81 
82  return 0;
83 }
static char uv__atomic_exchange_set(char volatile *target)
Definition: atomicops-inl.h:45
#define POST_COMPLETION_FOR_REQ(loop, req)
Definition: req-inl.h:76
Definition: uv.h:1780

References ACCESS_ONCE, assert(), handle, loop, POST_COMPLETION_FOR_REQ, uv__async_send(), uv__atomic_exchange_set(), and UV_HANDLE_CLOSING.

Referenced by fake_download(), uv__work_cancel(), and worker().

◆ uv_process_async_wakeup_req()

void uv_process_async_wakeup_req ( uv_loop_t loop,
uv_async_t handle,
uv_req_t req 
)

Definition at line 86 of file async.c.

87  {
88  assert(handle->type == UV_ASYNC);
89  assert(req->type == UV_WAKEUP);
90 
91  handle->async_sent = 0;
92 
93  if (handle->flags & UV_HANDLE_CLOSING) {
95  } else if (handle->async_cb != NULL) {
96  handle->async_cb(handle);
97  }
98 }
#define NULL
Definition: cris-opc.c:27

References assert(), handle, loop, NULL, req, UV_HANDLE_CLOSING, and uv_want_endgame().

Referenced by uv_process_reqs().