Github user ted-ross commented on a diff in the pull request:
https://github.com/apache/qpid-dispatch/pull/357#discussion_r209298303
--- Diff: src/router_core/transfer.c ---
@@ -717,6 +725,35 @@ void qdr_delivery_decref_CT(qdr_core_t *core,
qdr_delivery_t *dlv, const char *l
qdr_delete_delivery_internal_CT(core, dlv);
}
+static void qdr_process_tick_CT(qdr_core_t *core, qdr_action_t *action,
bool discard)
+{
+ if (discard)
+ return;
+
+ if (DEQ_SIZE(core->timer_list) == 0)
+ return;
+
+ qdr_timer_work_t *next_timer_work = 0;
+
+ qdr_timer_work_t *timer_work = DEQ_HEAD(core->timer_list);
+
+ while (timer_work) {
+ if (timer_work->timer_delay == 0) { // It is time to execute the
handler
+
+ timer_work->handler(core, timer_work->on_timer_context);
+ next_timer_work = DEQ_NEXT(timer_work);
+ DEQ_REMOVE(core->timer_list, timer_work);
+ free_qdr_timer_work_t(timer_work);
+ timer_work = next_timer_work;
+ }
+ else {
+ timer_work->timer_delay -=1;
+ timer_work = DEQ_NEXT(timer_work);
+ }
+
--- End diff --
As stated in another comment: This algorithm is going to be costly when
there are a large number of timers in the list. The tick handler must visit
every timer on every tick.
If the list were ordered by duration and the time stored in the timer_work
were relative (i.e. number of ticks after the previous work), then the tick
handler only needs to visit the head of the list.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]