From 63b9b1d47266d5c150fb72e6f38893c98a6b2847 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 4 Jun 2012 16:30:12 +0200 Subject: [PATCH] windows: move handle macros to handle-inl.h --- src/win/handle-inl.h | 41 +++++++++++++++++++++++++++++++++++++++++ src/win/internal.h | 37 ------------------------------------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/win/handle-inl.h b/src/win/handle-inl.h index 25829999..f069dd19 100644 --- a/src/win/handle-inl.h +++ b/src/win/handle-inl.h @@ -28,6 +28,47 @@ #include "internal.h" +#define DECREASE_ACTIVE_COUNT(loop, handle) \ + do { \ + if (--(handle)->activecnt == 0 && \ + !((handle)->flags & UV_HANDLE_CLOSING)) { \ + uv__handle_stop((handle)); \ + } \ + assert((handle)->activecnt >= 0); \ + } while (0) + + +#define INCREASE_ACTIVE_COUNT(loop, handle) \ + do { \ + if ((handle)->activecnt++ == 0) { \ + uv__handle_start((handle)); \ + } \ + assert((handle)->activecnt > 0); \ + } while (0) + + +#define DECREASE_PENDING_REQ_COUNT(handle) \ + do { \ + assert(handle->reqs_pending > 0); \ + handle->reqs_pending--; \ + \ + if (handle->flags & UV_HANDLE_CLOSING && \ + handle->reqs_pending == 0) { \ + uv_want_endgame(loop, (uv_handle_t*)handle); \ + } \ + } while (0) + + +#define uv__handle_close(handle) \ + do { \ + ngx_queue_remove(&(handle)->handle_queue); \ + (handle)->flags |= UV_HANDLE_CLOSED; \ + if ((handle)->close_cb) { \ + (handle)->close_cb((uv_handle_t*)(handle)); \ + } \ + } while (0) + + INLINE static void uv_handle_init(uv_loop_t* loop, uv_handle_t* handle) { handle->loop = loop; handle->flags = UV__HANDLE_REF; diff --git a/src/win/internal.h b/src/win/internal.h index 428078f3..dd7e5eb0 100644 --- a/src/win/internal.h +++ b/src/win/internal.h @@ -82,40 +82,12 @@ #define UV_HANDLE_POLL_SLOW 0x02000000 -#define DECREASE_PENDING_REQ_COUNT(handle) \ - do { \ - assert(handle->reqs_pending > 0); \ - handle->reqs_pending--; \ - \ - if (handle->flags & UV_HANDLE_CLOSING && \ - handle->reqs_pending == 0) { \ - uv_want_endgame(loop, (uv_handle_t*)handle); \ - } \ - } while (0) - #define UV_SUCCEEDED_WITHOUT_IOCP(result) \ ((result) && (handle->flags & UV_HANDLE_SYNC_BYPASS_IOCP)) #define UV_SUCCEEDED_WITH_IOCP(result) \ ((result) || (GetLastError() == ERROR_IO_PENDING)) -#define DECREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if (--(handle)->activecnt == 0 && \ - !((handle)->flags & UV_HANDLE_CLOSING)) { \ - uv__handle_stop((handle)); \ - } \ - assert((handle)->activecnt >= 0); \ - } while (0) - -#define INCREASE_ACTIVE_COUNT(loop, handle) \ - do { \ - if ((handle)->activecnt++ == 0) { \ - uv__handle_start((handle)); \ - } \ - assert((handle)->activecnt > 0); \ - } while (0) - #define REGISTER_HANDLE_REQ(loop, handle, req) \ do { \ INCREASE_ACTIVE_COUNT((loop), (handle)); \ @@ -128,15 +100,6 @@ uv__req_unregister((loop), (req)); \ } while (0) -#define uv__handle_close(handle) \ - do { \ - ngx_queue_remove(&(handle)->handle_queue); \ - (handle)->flags |= UV_HANDLE_CLOSED; \ - if ((handle)->close_cb) { \ - (handle)->close_cb((uv_handle_t*)(handle)); \ - } \ - } while (0) - /* * Requests (also see req-inl.h)