Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / APG / Timers / CB.cpp
blob69cd122ee3f8018448347150ac4b6c0b46f9964a
1 #include "ace/Log_Msg.h"
2 #include "CB.h"
3 #include "TimerDispatcher.h"
5 CB::CB () : count_(0)
7 ACE_TRACE ("CB::CB");
10 // Listing 1 code/ch20
11 int CB::handle_timeout (const ACE_Time_Value &,
12 const void *arg)
14 ACE_TRACE ("CB::handle_timeout");
16 const int *val = static_cast<const int*> (arg);
17 ACE_ASSERT ((*val) == timerID_);
19 ACE_UNUSED_ARG (val);
21 if (count_ == 5)
23 ACE_DEBUG ((LM_DEBUG,
24 ACE_TEXT ("Reseting interval for timer %d\n"),
25 timerID_));
27 // New interval is 10 ms.
28 ACE_Time_Value interval (0L, 1000L);
29 int status = Timer::instance ()->reset_interval
30 (timerID_, interval);
31 #if defined (ACE_NDEBUG)
32 ACE_UNUSED_ARG (status);
33 #else
34 ACE_ASSERT (status != -1);
35 #endif
38 if (count_++ == 10)
40 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Canceling %d\n"),
41 timerID_));
42 ACE_ASSERT ((Timer::instance ()->cancel (this)) != 0);
45 return 0;
47 // Listing 1
49 void
50 CB::setID (long timerID)
52 ACE_TRACE ("CB::setID");
53 timerID_ = timerID;
56 long
57 CB::getID ()
59 ACE_TRACE ("CB::getID");
60 return timerID_;
63 int
64 CB::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
66 ACE_TRACE ("CB::handle_close");
67 return 0;