2 * Changing the interval
5 #include "ace/OS_NS_time.h"
6 #include "ace/Log_Msg.h"
7 #include "ace/Reactor.h"
8 #include "ace/Event_Handler.h"
10 class MyTimerHandler
: public ACE_Event_Handler
13 int handle_timeout (const ACE_Time_Value
¤t_time
,
16 time_t epoch
= ((timespec_t
)current_time
).tv_sec
;
18 ACE_TEXT ("handle_timeout: %s"),
19 ACE_OS::ctime(&epoch
)));
24 // Listing 1 code/ch07
25 class SigintHandler
: public ACE_Event_Handler
28 SigintHandler (long timerId
, int currentInterval
)
29 : ACE_Event_Handler(),
31 currentInterval_(currentInterval
)
35 int handle_signal (int, siginfo_t
* = 0, ucontext_t
* = 0)
38 ACE_TEXT ("Resetting interval of timer ")
39 ACE_TEXT ("%d to %d\n"),
41 ++this->currentInterval_
));
42 ACE_Time_Value
newInterval (this->currentInterval_
);
43 ACE_Reactor::instance()->
44 reset_timer_interval (this->timerId_
, newInterval
);
54 int ACE_TMAIN (int, ACE_TCHAR
*[])
56 ACE_Time_Value
initialDelay (3);
57 ACE_Time_Value
interval (5);
59 // Listing 2 code/ch07
60 MyTimerHandler
*handler
= new MyTimerHandler ();
63 ACE_Reactor::instance ()->schedule_timer (handler
,
69 // Listing 3 code/ch07
70 SigintHandler
*handleSigint
=
71 new SigintHandler (timerId
, 5);
72 ACE_Reactor::instance ()->register_handler (SIGINT
,
76 ACE_Reactor::instance ()->run_reactor_event_loop ();