[ 
https://issues.apache.org/jira/browse/DISPATCH-1099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16576444#comment-16576444
 ] 

ASF GitHub Bot commented on DISPATCH-1099:
------------------------------------------

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.


> Add a timer facility for the core thread
> ----------------------------------------
>
>                 Key: DISPATCH-1099
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-1099
>             Project: Qpid Dispatch
>          Issue Type: Improvement
>          Components: Container
>    Affects Versions: 1.2.0
>            Reporter: Ganesh Murthy
>            Assignee: Ganesh Murthy
>            Priority: Major
>
> Currently there is qd_router_timer_handler() in router_node.c which schedules 
> a timer every second/ Extend this to send the timer action into core so core 
> can execute some periodic actions.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to