Hi Daniel,
> Instead of creating a new rntl trigger
> for each Counter object move this part
> to the rtnl core. Only one update trigger
> will be registered at RTNL. The minimum
> interval will used for the timeout callback.
patch looks good, but here are some minor nitpicks.
> +static gint compare_interval(gconstpointer a, gconstpointer b)
> +{
> + guint i = GPOINTER_TO_UINT(a);
> + guint j = GPOINTER_TO_UINT(b);
> +
> + return i - j;
> +}
So personally I would do val_a - val_b to give some relation to the
pointer, but i and j work as well.
> +unsigned int __connman_rtnl_update_interval_add(unsigned int interval)
> +{
> + guint min;
> +
> + if (interval == 0)
> + return 0;
> +
> + update_list = g_slist_insert_sorted(update_list,
> + GUINT_TO_POINTER(interval), compare_interval);
> +
> + min = GPOINTER_TO_UINT(g_slist_nth_data(update_list, 0));
> + if (min < update_interval) {
> + update_interval_callback(min);
> + __connman_rtnl_request_update();
> + }
> +
> + return update_interval;
> +}
> +
> +unsigned int __connman_rtnl_update_interval_remove(unsigned int interval)
> +{
> + guint min = G_MAXUINT;
> +
> + if (interval == 0)
> + return 0;
> +
> + update_list = g_slist_remove(update_list, GINT_TO_POINTER(interval));
> +
> + if (g_slist_length(update_list) != 0)
> + min = GPOINTER_TO_UINT(g_slist_nth_data(update_list, 0));
I do prefer checks like g_slist_length() > 0. However in this case
actually checking for update_list != NULL might be better.
Regards
Marcel
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman