Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / APG / Timers / PTimerDispatcher.cpp
blobdbb5b6477e3e084e5ea610a6077db519cb85d7bf
1 #include "PTimerDispatcher.h"
3 void PTimer_Dispatcher::wait_for_event ()
5 ACE_TRACE ("PTimer_Dispatcher::wait_for_event");
7 while (1)
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 ();
16 else
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 long
29 PTimer_Dispatcher::schedule (PCB *cb,
30 void *arg,
31 const ACE_Time_Value &abs_time,
32 const ACE_Time_Value &interval)
34 ACE_TRACE ("PTimer_Dispatcher::schedule_timer");
36 return this->timer_queue_->schedule
37 (cb, arg, abs_time, interval);
40 int
41 PTimer_Dispatcher::cancel (PCB *cb,
42 int dont_call_handle_close)
44 ACE_TRACE ("PTimer_Dispatcher::cancel");
45 return timer_queue_->cancel (cb, dont_call_handle_close);
48 void PTimer_Dispatcher::set (PTimerQueue *timer_queue)
50 ACE_TRACE ("PTimer_Dispatcher::set");
52 timer_queue_ = timer_queue;
55 int
56 PTimer_Dispatcher::reset_interval (long timer_id,
57 const ACE_Time_Value &interval)
59 ACE_TRACE ("PTimer_Dispatcher::reset_interval");
61 return timer_queue_->reset_interval (timer_id, interval);
63 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, PTimer_Dispatcher, ACE_Null_Mutex);