Skip to content

Commit

Permalink
remove active_events in timer
Browse files Browse the repository at this point in the history
  • Loading branch information
qgymib committed Oct 7, 2023
1 parent bd15674 commit 14b45cd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
23 changes: 13 additions & 10 deletions ev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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" */
Expand All @@ -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))
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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" */
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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)
{
Expand Down
12 changes: 12 additions & 0 deletions src/handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

0 comments on commit 14b45cd

Please sign in to comment.