From 14b45cd2e803fd65c6f88403c6d965c9d9cfe22d Mon Sep 17 00:00:00 2001 From: qgymib Date: Sat, 7 Oct 2023 11:19:00 +0800 Subject: [PATCH] remove active_events in timer --- ev.c | 23 +++++++++++++---------- src/handle.c | 4 ++-- src/handle.h | 12 ++++++++++++ src/timer.c | 4 ++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ev.c b/ev.c index 9f26d6e42..c40a01c32 100644 --- a/ev.c +++ b/ev.c @@ -244,8 +244,8 @@ EV_LOCAL void ev__async_exit_force(ev_async_t* handle); //////////////////////////////////////////////////////////////////////////////// // FILE: src/handle.h -// SIZE: 4242 -// SHA-256: da6ff247fe73aa9705bf038f0e66c3247b4aa9fc8ad9ca4800276ec61d94aac7 +// SIZE: 4353 +// SHA-256: 53260632044cb152f67e80b8a53ae58be5082b0345d8aebc8705fc233387401d //////////////////////////////////////////////////////////////////////////////// #line 1 "src/handle.h" #ifndef __EV_HANDLE_INTERNAL_H__ @@ -310,6 +310,9 @@ EV_LOCAL void ev__handle_init(ev_loop_t* loop, ev_handle_t* handle, ev_role_t ro */ EV_LOCAL void ev__handle_exit(ev_handle_t* handle, ev_handle_cb close_cb); +EV_LOCAL void ev__handle_active(ev_handle_t* handle); +EV_LOCAL void ev__handle_deactive(ev_handle_t* handle); + /** * @brief Add active event counter. If active event counter is non-zero, * #EV_HANDLE_ACTIVE is appended. @@ -2279,8 +2282,8 @@ EV_LOCAL int ev__fs_remove(const char* path, int recursive) //////////////////////////////////////////////////////////////////////////////// // FILE: src/handle.c -// SIZE: 4387 -// SHA-256: 0ade9e28b8ffa1155d151d49a9dd2b5836ea886de9c6d74d28050edda636784f +// SIZE: 4391 +// SHA-256: 800a87ff5a35c17c141ea53311ac3a60071fe55592cde8d5f00aed3f3e86d370 //////////////////////////////////////////////////////////////////////////////// #line 1 "src/handle.c" /* AMALGAMATE: #include "ev.h" */ @@ -2293,7 +2296,7 @@ EV_LOCAL int ev__fs_remove(const char* path, int recursive) * @see ev__handle_event_dec() * @param[in] handle handler */ -static void ev__handle_deactive(ev_handle_t* handle) +EV_LOCAL void ev__handle_deactive(ev_handle_t* handle) { if (!(handle->data.flags & EV_HANDLE_ACTIVE)) { @@ -2311,7 +2314,7 @@ static void ev__handle_deactive(ev_handle_t* handle) * @see ev__handle_event_add() * @param[in] handle handler */ -static void ev__handle_active(ev_handle_t* handle) +EV_LOCAL void ev__handle_active(ev_handle_t* handle) { if (handle->data.flags & EV_HANDLE_ACTIVE) { @@ -5236,8 +5239,8 @@ EV_LOCAL void ev__threadpool_process(ev_loop_t* loop) //////////////////////////////////////////////////////////////////////////////// // FILE: src/timer.c -// SIZE: 2546 -// SHA-256: 423fd61d22de01be995765d2696b388574d944c09f6ab57f657456715da0b1ee +// SIZE: 2542 +// SHA-256: 6727d0797948f1d3b71507363798aa1884780e6ffa804eb2a85c022d6883baf7 //////////////////////////////////////////////////////////////////////////////// #line 1 "src/timer.c" /* AMALGAMATE: #include "ev.h" */ @@ -5336,7 +5339,7 @@ int ev_timer_start(ev_timer_t* handle, ev_timer_cb cb, uint64_t timeout, uint64_ { EV_ABORT("duplicate timer"); } - ev__handle_event_add(&handle->base); + ev__handle_active(&handle->base); return 0; } @@ -5348,7 +5351,7 @@ void ev_timer_stop(ev_timer_t* handle) return; } - ev__handle_event_dec(&handle->base); + ev__handle_deactive(&handle->base); ev_map_erase(&handle->base.loop->timer.heap, &handle->node); } diff --git a/src/handle.c b/src/handle.c index 0075c1e1d..44d9e287c 100644 --- a/src/handle.c +++ b/src/handle.c @@ -8,7 +8,7 @@ * @see ev__handle_event_dec() * @param[in] handle handler */ -static void ev__handle_deactive(ev_handle_t* handle) +EV_LOCAL void ev__handle_deactive(ev_handle_t* handle) { if (!(handle->data.flags & EV_HANDLE_ACTIVE)) { @@ -26,7 +26,7 @@ static void ev__handle_deactive(ev_handle_t* handle) * @see ev__handle_event_add() * @param[in] handle handler */ -static void ev__handle_active(ev_handle_t* handle) +EV_LOCAL void ev__handle_active(ev_handle_t* handle) { if (handle->data.flags & EV_HANDLE_ACTIVE) { diff --git a/src/handle.h b/src/handle.h index 80f87c32c..84791b4f2 100644 --- a/src/handle.h +++ b/src/handle.h @@ -60,6 +60,18 @@ EV_LOCAL void ev__handle_init(ev_loop_t* loop, ev_handle_t* handle, ev_role_t ro */ EV_LOCAL void ev__handle_exit(ev_handle_t* handle, ev_handle_cb close_cb); +/** + * @brief Active handle. + * @param[in] handle Handler. + */ +EV_LOCAL void ev__handle_active(ev_handle_t* handle); + +/** + * @brief De-active handle. + * @param[in] handle Handler. + */ +EV_LOCAL void ev__handle_deactive(ev_handle_t* handle); + /** * @brief Add active event counter. If active event counter is non-zero, * #EV_HANDLE_ACTIVE is appended. diff --git a/src/timer.c b/src/timer.c index 6270bc9f6..cbb6ab579 100644 --- a/src/timer.c +++ b/src/timer.c @@ -94,7 +94,7 @@ int ev_timer_start(ev_timer_t* handle, ev_timer_cb cb, uint64_t timeout, uint64_ { EV_ABORT("duplicate timer"); } - ev__handle_event_add(&handle->base); + ev__handle_active(&handle->base); return 0; } @@ -106,6 +106,6 @@ void ev_timer_stop(ev_timer_t* handle) return; } - ev__handle_event_dec(&handle->base); + ev__handle_deactive(&handle->base); ev_map_erase(&handle->base.loop->timer.heap, &handle->node); }