[Ace-users] [ace-users] Odd action when ACE_Event_Handler::handle_timeout returns -1.

Douglas C. Schmidt schmidt at dre.vanderbilt.edu
Thu Dec 20 08:10:37 CST 2007


Hi,

        Thanks for providing the version info.

>Version 5.6.2
>Host: windows xp sp2 / SuSE Linux Enterprise Server 10
>Compiler: VS 2003 / Gcc 3.3.3
>
>I schedule three timers on ACE_Event_Handler, here I call them
>timer_id1, timer_id2 and timer_id3. In handle_timeout of timer_id1, I
>returns -1, which I think timer_id1 will be canceled and unregistered
>from reactor. But I found that when returns -1, all three timers are
>canceled and unregistered from the reactor. I think this action is
>odd.
>
>I only want one timer to be canceled in handle_timeout, how ?

Please see this API:

  /**
   * Cancel timer.
   *
   * Cancel timer associated with @a timer_id that was returned from
   * the schedule_timer() method.  If arg is non-NULL then it will be
   * set to point to the ``magic cookie'' argument passed in when the
   * handler was registered.  This makes it possible to free up the
   * memory and avoid memory leaks.  Returns 1 if cancellation
   * succeeded and 0 if the @a timer_id wasn't found.
   *
   * On successful cancellation, ACE_Event_Handler::handle_close()
   * will be called with <ACE_Event_Handler::TIMER_MASK>.
   * ACE_Event_Handler::remove_reference() will also be called.
   */
  virtual int cancel_timer (long timer_id,
                            const void **arg = 0,
                            int dont_call_handle_close = 1);


You'll need to keep track of the timer id in order to cancel a
particular timer.

Thanks,

        Doug


-- 
Dr. Douglas C. Schmidt                       Professor and Associate Chair
Electrical Engineering and Computer Science  TEL: (615) 343-8197
Vanderbilt University                        WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203                          NET: d.schmidt at vanderbilt.edu



More information about the Ace-users mailing list