25 #define UV_LOOP_WATCHER_DEFINE(name, type) \
26 int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
27 uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \
28 handle->name##_cb = NULL; \
32 int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \
33 if (uv__is_active(handle)) return 0; \
34 if (cb == NULL) return UV_EINVAL; \
35 QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \
36 handle->name##_cb = cb; \
37 uv__handle_start(handle); \
41 int uv_##name##_stop(uv_##name##_t* handle) { \
42 if (!uv__is_active(handle)) return 0; \
43 QUEUE_REMOVE(&handle->queue); \
44 uv__handle_stop(handle); \
48 void uv__run_##name(uv_loop_t* loop) { \
52 QUEUE_MOVE(&loop->name##_handles, &queue); \
53 while (!QUEUE_EMPTY(&queue)) { \
54 q = QUEUE_HEAD(&queue); \
55 h = QUEUE_DATA(q, uv_##name##_t, queue); \
57 QUEUE_INSERT_TAIL(&loop->name##_handles, q); \
62 void uv__##name##_close(uv_##name##_t* handle) { \
63 uv_##name##_stop(handle); \
#define UV_LOOP_WATCHER_DEFINE(name, type)