예제 #1
0
template <class TYPE, class FUNCTOR, class ACE_LOCK> long
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::schedule (const TYPE &type,
                                                 const void *act,
                                                 const ACE_Time_Value &future_time,
                                                 const ACE_Time_Value &interval)
{
  ACE_TRACE ("ACE_Timer_List_T::schedule");
  ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1));

  // Place in the middle of the list where it belongs (i.e., sorted in
  // ascending order of absolute time to expire).
  ACE_Timer_Node_T<TYPE> *after = this->head_->get_next ();

  while (after != this->head_
         && future_time > after->get_timer_value ())
      after = after->get_next ();

  ACE_Timer_Node_T<TYPE> *temp = this->alloc_node ();

  temp->set (type,
             act,
             future_time,
             interval,
             after->get_prev (),
             after,
             (long) temp);

  after->get_prev ()->set_next (temp);
  after->set_prev (temp);

  return ACE_reinterpret_cast (long, temp);
}
예제 #2
0
template <class TYPE, class FUNCTOR, class ACE_LOCK> void
ACE_Timer_List_T<TYPE, FUNCTOR, ACE_LOCK>::reschedule (ACE_Timer_Node_T<TYPE> *expired)
{
  ACE_TRACE ("ACE_Timer_List_T::reschedule");

  ACE_Timer_Node_T<TYPE> *after = this->head_->get_next ();

  // Locate the proper position in the queue.

  while (after != this->head_
         && expired->get_timer_value () > after->get_timer_value ())
      after = after->get_next ();

  expired->set_next (after);
  expired->set_prev (after->get_prev ());
  after->get_prev ()->set_next (expired);
  after->set_prev (expired);
}