diff --git a/src/unix/check.c b/src/unix/check.c index 2584b327..cc5d3c7e 100644 --- a/src/unix/check.c +++ b/src/unix/check.c @@ -68,3 +68,8 @@ int uv_check_stop(uv_check_t* check) { return 0; } + + +int uv__check_active(const uv_check_t* handle) { + return ev_is_active(&handle->check_watcher); +} diff --git a/src/unix/core.c b/src/unix/core.c index a83079ea..09987e99 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -340,20 +340,16 @@ void uv__req_init(uv_loop_t* loop, uv_req_t* req) { int uv_is_active(uv_handle_t* handle) { switch (handle->type) { - case UV_TIMER: - return ev_is_active(&((uv_timer_t*)handle)->timer_watcher); - - case UV_PREPARE: - return ev_is_active(&((uv_prepare_t*)handle)->prepare_watcher); - - case UV_CHECK: - return ev_is_active(&((uv_check_t*)handle)->check_watcher); - - case UV_IDLE: - return ev_is_active(&((uv_idle_t*)handle)->idle_watcher); - - default: - return 1; + case UV_CHECK: + return uv__check_active((uv_check_t*)handle); + case UV_IDLE: + return uv__idle_active((uv_idle_t*)handle); + case UV_PREPARE: + return uv__prepare_active((uv_prepare_t*)handle); + case UV_TIMER: + return uv__timer_active((uv_timer_t*)handle); + default: + return 1; } } diff --git a/src/unix/idle.c b/src/unix/idle.c index 0fab4db2..bcefd6a1 100644 --- a/src/unix/idle.c +++ b/src/unix/idle.c @@ -67,3 +67,8 @@ int uv_idle_stop(uv_idle_t* idle) { return 0; } + + +int uv__idle_active(const uv_idle_t* handle) { + return ev_is_active(&handle->idle_watcher); +} diff --git a/src/unix/internal.h b/src/unix/internal.h index 4f14eb46..2f5f54cb 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -139,6 +139,11 @@ void uv__udp_finish_close(uv_udp_t* handle); /* fs */ void uv__fs_event_destroy(uv_fs_event_t* handle); +int uv__check_active(const uv_check_t* handle); +int uv__idle_active(const uv_idle_t* handle); +int uv__prepare_active(const uv_prepare_t* handle); +int uv__timer_active(const uv_timer_t* handle); + #define UV__F_IPC (1 << 0) #define UV__F_NONBLOCK (1 << 1) int uv__make_socketpair(int fds[2], int flags); diff --git a/src/unix/prepare.c b/src/unix/prepare.c index 52417a5e..59ddf8c2 100644 --- a/src/unix/prepare.c +++ b/src/unix/prepare.c @@ -67,3 +67,8 @@ int uv_prepare_stop(uv_prepare_t* prepare) { } return 0; } + + +int uv__prepare_active(const uv_prepare_t* handle) { + return ev_is_active(&handle->prepare_watcher); +} diff --git a/src/unix/timer.c b/src/unix/timer.c index fe33dd39..e719c20e 100644 --- a/src/unix/timer.c +++ b/src/unix/timer.c @@ -23,11 +23,6 @@ #include -static int uv__timer_active(const uv_timer_t* timer) { - return timer->flags & UV_TIMER_ACTIVE; -} - - static int uv__timer_repeating(const uv_timer_t* timer) { return timer->flags & UV_TIMER_REPEAT; } @@ -120,3 +115,8 @@ int64_t uv_timer_get_repeat(uv_timer_t* timer) { assert(timer->type == UV_TIMER); return (int64_t)(1000 * timer->timer_watcher.repeat); } + + +int uv__timer_active(const uv_timer_t* timer) { + return timer->flags & UV_TIMER_ACTIVE; +}