Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / JAWS3 / jaws3 / Task_Timer.cpp
bloba24e8e53e374c697f6b76db919c7ae277597a177
1 #ifndef JAWS_BUILD_DLL
2 #define JAWS_BUILD_DLL
3 #endif
5 #include "ace/OS_NS_sys_time.h"
7 #include "jaws3/Task_Timer.h"
8 #include "jaws3/Timer_Helpers.h"
11 JAWS_Task_Timer::JAWS_Task_Timer ()
13 this->timer_queue_.activate ();
17 void
18 JAWS_Task_Timer::schedule_timer ( long *timer_id
19 , const ACE_Time_Value &delta
20 , JAWS_Event_Completer *completer
21 , void *act
24 JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
25 if (eh == 0
26 || (*timer_id =
27 this->timer_queue_.schedule ( eh
28 , 0
29 , delta + ACE_OS::gettimeofday ()))
30 == -1)
32 JAWS_Event_Result timer_result ( 0
33 , JAWS_Event_Result::JE_ERROR
34 , JAWS_Event_Result::JE_TIMER_FAIL
37 if (completer)
38 completer->timer_complete (timer_result, act);
40 delete eh;
45 void
46 JAWS_Task_Timer::schedule_absolute_timer ( long *timer_id
47 , const ACE_Time_Value &tv
48 , JAWS_Event_Completer *completer
49 , void *act
52 JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
53 if (eh == 0
54 || (*timer_id = this->timer_queue_.schedule (eh, 0, tv)) == -1)
56 JAWS_Event_Result timer_result ( 0
57 , JAWS_Event_Result::JE_ERROR
58 , JAWS_Event_Result::JE_TIMER_FAIL
61 if (completer)
62 completer->timer_complete (timer_result, act);
64 delete eh;
69 void
70 JAWS_Task_Timer::schedule_interval_timer ( long *timer_id
71 , const ACE_Time_Value &interval
72 , JAWS_Event_Completer *completer
73 , void *act
76 JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
77 if (eh == 0
78 || (*timer_id =
79 this->timer_queue_.schedule ( eh
80 , 0
81 , interval + ACE_OS::gettimeofday ()
82 , interval
84 == -1)
86 JAWS_Event_Result timer_result ( 0
87 , JAWS_Event_Result::JE_ERROR
88 , JAWS_Event_Result::JE_TIMER_FAIL
91 if (completer)
92 completer->timer_complete (timer_result, act);
94 delete eh;
99 void
100 JAWS_Task_Timer::cancel_timer (long timer_id)
102 this->timer_queue_.cancel (timer_id);