diff --git a/src/win/async.c b/src/win/async.c index 99e0fa56..18480237 100644 --- a/src/win/async.c +++ b/src/win/async.c @@ -23,6 +23,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/core.c b/src/win/core.c index 3405c98d..7a355803 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -28,6 +28,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/fs-event.c b/src/win/fs-event.c index 71b37c61..ccf941d1 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -27,6 +27,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/handle-inl.h b/src/win/handle-inl.h new file mode 100644 index 00000000..d59003fe --- /dev/null +++ b/src/win/handle-inl.h @@ -0,0 +1,104 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include + +#include "uv.h" +#include "internal.h" + + +INLINE static void uv_handle_init(uv_loop_t* loop, uv_handle_t* handle) { + handle->loop = loop; + handle->flags = UV__HANDLE_REF; + ngx_queue_insert_tail(&loop->handle_queue, &handle->handle_queue); + + loop->counters.handle_init++; +} + + +INLINE static void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle) { + if (!(handle->flags & UV_HANDLE_ENDGAME_QUEUED)) { + handle->flags |= UV_HANDLE_ENDGAME_QUEUED; + + handle->endgame_next = loop->endgame_handles; + loop->endgame_handles = handle; + } +} + + +INLINE static void uv_process_endgames(uv_loop_t* loop) { + uv_handle_t* handle; + + while (loop->endgame_handles) { + handle = loop->endgame_handles; + loop->endgame_handles = handle->endgame_next; + + handle->flags &= ~UV_HANDLE_ENDGAME_QUEUED; + + switch (handle->type) { + case UV_TCP: + uv_tcp_endgame(loop, (uv_tcp_t*) handle); + break; + + case UV_NAMED_PIPE: + uv_pipe_endgame(loop, (uv_pipe_t*) handle); + break; + + case UV_TTY: + uv_tty_endgame(loop, (uv_tty_t*) handle); + break; + + case UV_UDP: + uv_udp_endgame(loop, (uv_udp_t*) handle); + break; + + case UV_POLL: + uv_poll_endgame(loop, (uv_poll_t*) handle); + break; + + case UV_TIMER: + uv_timer_endgame(loop, (uv_timer_t*) handle); + break; + + case UV_PREPARE: + case UV_CHECK: + case UV_IDLE: + uv_loop_watcher_endgame(loop, handle); + break; + + case UV_ASYNC: + uv_async_endgame(loop, (uv_async_t*) handle); + break; + + case UV_PROCESS: + uv_process_endgame(loop, (uv_process_t*) handle); + break; + + case UV_FS_EVENT: + uv_fs_event_endgame(loop, (uv_fs_event_t*) handle); + break; + + default: + assert(0); + break; + } + } +} diff --git a/src/win/handle.c b/src/win/handle.c index a3abb0ab..9343d256 100644 --- a/src/win/handle.c +++ b/src/win/handle.c @@ -24,6 +24,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" uv_handle_type uv_guess_handle(uv_file file) { @@ -62,15 +63,6 @@ int uv_is_active(const uv_handle_t* handle) { } -void uv_handle_init(uv_loop_t* loop, uv_handle_t* handle) { - handle->loop = loop; - handle->flags = UV__HANDLE_REF; - ngx_queue_insert_tail(&loop->handle_queue, &handle->handle_queue); - - loop->counters.handle_init++; -} - - void uv_close(uv_handle_t* handle, uv_close_cb cb) { uv_loop_t* loop = handle->loop; @@ -150,73 +142,3 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) { int uv_is_closing(const uv_handle_t* handle) { return handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED); } - - -void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle) { - if (!(handle->flags & UV_HANDLE_ENDGAME_QUEUED)) { - handle->flags |= UV_HANDLE_ENDGAME_QUEUED; - - handle->endgame_next = loop->endgame_handles; - loop->endgame_handles = handle; - } -} - - -void uv_process_endgames(uv_loop_t* loop) { - uv_handle_t* handle; - - while (loop->endgame_handles) { - handle = loop->endgame_handles; - loop->endgame_handles = handle->endgame_next; - - handle->flags &= ~UV_HANDLE_ENDGAME_QUEUED; - - switch (handle->type) { - case UV_TCP: - uv_tcp_endgame(loop, (uv_tcp_t*) handle); - break; - - case UV_NAMED_PIPE: - uv_pipe_endgame(loop, (uv_pipe_t*) handle); - break; - - case UV_TTY: - uv_tty_endgame(loop, (uv_tty_t*) handle); - break; - - case UV_UDP: - uv_udp_endgame(loop, (uv_udp_t*) handle); - break; - - case UV_POLL: - uv_poll_endgame(loop, (uv_poll_t*) handle); - break; - - case UV_TIMER: - uv_timer_endgame(loop, (uv_timer_t*) handle); - break; - - case UV_PREPARE: - case UV_CHECK: - case UV_IDLE: - uv_loop_watcher_endgame(loop, handle); - break; - - case UV_ASYNC: - uv_async_endgame(loop, (uv_async_t*) handle); - break; - - case UV_PROCESS: - uv_process_endgame(loop, (uv_process_t*) handle); - break; - - case UV_FS_EVENT: - uv_fs_event_endgame(loop, (uv_fs_event_t*) handle); - break; - - default: - assert(0); - break; - } - } -} diff --git a/src/win/internal.h b/src/win/internal.h index 12e73f32..428078f3 100644 --- a/src/win/internal.h +++ b/src/win/internal.h @@ -32,6 +32,7 @@ /* * Handles + * (also see handle-inl.h) */ /* Used by all handles. */ @@ -81,9 +82,6 @@ #define UV_HANDLE_POLL_SLOW 0x02000000 -void uv_want_endgame(uv_loop_t* loop, uv_handle_t* handle); -void uv_process_endgames(uv_loop_t* loop); - #define DECREASE_PENDING_REQ_COUNT(handle) \ do { \ assert(handle->reqs_pending > 0); \ @@ -139,11 +137,6 @@ void uv_process_endgames(uv_loop_t* loop); } \ } while (0) -/* - * Handles - */ -void uv_handle_init(uv_loop_t* loop, uv_handle_t* handle); - /* * Requests (also see req-inl.h) diff --git a/src/win/loop-watcher.c b/src/win/loop-watcher.c index c573cd7d..a753a063 100644 --- a/src/win/loop-watcher.c +++ b/src/win/loop-watcher.c @@ -23,6 +23,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) { diff --git a/src/win/pipe.c b/src/win/pipe.c index bb21eaeb..59511734 100644 --- a/src/win/pipe.c +++ b/src/win/pipe.c @@ -26,6 +26,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/poll.c b/src/win/poll.c index 5a2d5e95..ba31ae9e 100644 --- a/src/win/poll.c +++ b/src/win/poll.c @@ -24,6 +24,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/process.c b/src/win/process.c index 0acff3ee..88cb17b6 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -27,6 +27,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/stream.c b/src/win/stream.c index 94551a43..08c62eda 100644 --- a/src/win/stream.c +++ b/src/win/stream.c @@ -23,6 +23,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/tcp.c b/src/win/tcp.c index 937eae11..82e2d8d8 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -23,6 +23,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/timer.c b/src/win/timer.c index 810960c6..69638bc9 100644 --- a/src/win/timer.c +++ b/src/win/timer.c @@ -25,6 +25,7 @@ #include "uv.h" #include "internal.h" #include "tree.h" +#include "handle-inl.h" void uv_update_time(uv_loop_t* loop) { diff --git a/src/win/tty.c b/src/win/tty.c index aaa29b6e..f1c02474 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -26,6 +26,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/src/win/udp.c b/src/win/udp.c index 4ff71c45..cdd1c153 100644 --- a/src/win/udp.c +++ b/src/win/udp.c @@ -23,6 +23,7 @@ #include "uv.h" #include "internal.h" +#include "handle-inl.h" #include "req-inl.h" diff --git a/uv.gyp b/uv.gyp index ec674073..4faf7d83 100644 --- a/uv.gyp +++ b/uv.gyp @@ -142,6 +142,7 @@ 'src/win/fs-event.c', 'src/win/getaddrinfo.c', 'src/win/handle.c', + 'src/win/handle-inl.h', 'src/win/internal.h', 'src/win/loop-watcher.c', 'src/win/pipe.c',