1 #include "TimerDispatcher.h"
3 void Timer_Dispatcher::wait_for_event ()
5 ACE_TRACE ("Timer_Dispatcher::wait_for_event");
9 ACE_Time_Value max_tv
= timer_queue_
->gettimeofday ();
11 ACE_Time_Value
*this_timeout
=
12 this->timer_queue_
->calculate_timeout (&max_tv
);
14 if (*this_timeout
== ACE_Time_Value::zero
)
15 this->timer_queue_
->expire ();
18 // Convert to absolute time.
19 ACE_Time_Value next_timeout
=
20 timer_queue_
->gettimeofday ();
21 next_timeout
+= *this_timeout
;
22 if (this->timer_
.wait (&next_timeout
) == -1 )
23 this->timer_queue_
->expire ();
28 // Listing 2 code/ch20
30 Timer_Dispatcher::schedule (ACE_Event_Handler
*cb
,
32 const ACE_Time_Value
&abs_time
,
33 const ACE_Time_Value
&interval
)
35 ACE_TRACE ("Timer_Dispatcher::schedule_timer");
37 return this->timer_queue_
->schedule
38 (cb
, arg
, abs_time
, interval
);
41 // Listing 3 code/ch20
43 Timer_Dispatcher::cancel (ACE_Event_Handler
*cb
,
44 int dont_call_handle_close
)
46 ACE_TRACE ("Timer_Dispatcher::cancel");
47 return timer_queue_
->cancel (cb
, dont_call_handle_close
);
50 // Listing 4 code/ch20
51 void Timer_Dispatcher::set (ACE_Timer_Queue
*timer_queue
)
53 ACE_TRACE ("Timer_Dispatcher::set");
55 timer_queue_
= timer_queue
;
60 Timer_Dispatcher::reset_interval (long timer_id
,
61 const ACE_Time_Value
&interval
)
63 ACE_TRACE ("Timer_Dispatcher::reset_interval");
65 return timer_queue_
->reset_interval(timer_id
, interval
);
67 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, Timer_Dispatcher
, ACE_Null_Mutex
);