diff --git a/uv-win.c b/uv-win.c index 4314ef6e..a7ada030 100644 --- a/uv-win.c +++ b/uv-win.c @@ -1347,6 +1347,19 @@ int uv_idle_stop(uv_handle_t* handle) { } +int uv_is_active(uv_handle_t* handle) { + switch (handle->type) { + case UV_IDLE: + case UV_PREPARE: + case UV_CHECK: + return (handle->flags & UV_HANDLE_ACTIVE) ? 1 : 0; + + default: + return 1; + } +} + + int uv_async_init(uv_handle_t* handle, uv_async_cb async_cb, uv_close_cb close_cb, void* data) { uv_req_t* req; diff --git a/uv.h b/uv.h index e0e7430b..2b2744ee 100644 --- a/uv.h +++ b/uv.h @@ -248,6 +248,11 @@ int uv_idle_init(uv_handle_t* handle, uv_close_cb close_cb, void* data); int uv_idle_start(uv_handle_t* handle, uv_loop_cb cb); int uv_idle_stop(uv_handle_t* handle); +/* Returns 1 if the prepare/check/idle handle has been started, 0 otherwise. + * For other handle types this always returns 1. + */ +int uv_is_active(uv_handle_t* handle); + /* libev wrapper. uv_async_send wakes up the event loop and calls the async * handle's callback There is no guarantee that every uv_async_send call * leads to exactly one invocation of the callback; The only guarantee is