Skip to content

Commit 79a346a

Browse files
committed
MINOR: event_hdl: add event_hdl_sub_list_empty() helper func
event_hdl_sub_list_empty() may be used to know if the subscription list passed as argument is empty or not (ie: if there currently are any subcribers or not). It can be useful to know if the subscription is empty is order to avoid unecessary preparation work and skip event publishing to save CPU time if we already know that no one is interested in tracking the changes for a given subscription list.
1 parent 5dcf201 commit 79a346a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/haproxy/event_hdl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@ static inline uint32_t event_hdl_async_equeue_size(event_hdl_async_equeue *queue
499499
/* use this to initialize <sub_list> event subscription list */
500500
void event_hdl_sub_list_init(event_hdl_sub_list *sub_list);
501501

502+
/* check if <sub_list> subscriber count is 0 or not */
503+
static inline int event_hdl_sub_list_empty(event_hdl_sub_list *sub_list)
504+
{
505+
return MT_LIST_ISEMPTY(&sub_list->head);
506+
}
507+
502508
/* use this function when you need to destroy <sub_list>
503509
* event subscription list
504510
* All subscriptions will be removed and properly freed according

0 commit comments

Comments
 (0)