]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: event_hdl: add event_hdl_sub_list_empty() helper func
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 18 Oct 2024 16:45:45 +0000 (18:45 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 7 Nov 2024 10:35:55 +0000 (11:35 +0100)
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.

include/haproxy/event_hdl.h

index 5a7ee661350eb473771430ffe53c5df96e0805b8..7985e700173fdf5a212dd98c358e232d27069a52 100644 (file)
@@ -499,6 +499,12 @@ static inline uint32_t event_hdl_async_equeue_size(event_hdl_async_equeue *queue
 /* use this to initialize <sub_list> event subscription list */
 void event_hdl_sub_list_init(event_hdl_sub_list *sub_list);
 
+/* check if <sub_list> subscriber count is 0 or not */
+static inline int event_hdl_sub_list_empty(event_hdl_sub_list *sub_list)
+{
+       return MT_LIST_ISEMPTY(&sub_list->head);
+}
+
 /* use this function when you need to destroy <sub_list>
  * event subscription list
  * All subscriptions will be removed and properly freed according