Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / APG / Timers / PCB.cpp
blobabd93721818d3df1547faa2a28eb224ab6776d14
1 #include "ace/Log_Msg.h"
2 #include "PCB.h"
3 #include "PTimerDispatcher.h"
5 PCB::PCB() : count_(0)
7 ACE_TRACE ("PCB::PCB");
10 PCB::~PCB()
14 int PCB::handleEvent (const void *arg)
16 ACE_TRACE ("PCB::handleEvent");
18 const int *val = static_cast<const int*> (arg);
19 ACE_ASSERT ((*val) == timerID_);
21 ACE_UNUSED_ARG (val);
23 ACE_DEBUG ((LM_DEBUG,
24 ACE_TEXT("Timer %d expiry handled by thread %t\n"),
25 timerID_));
26 if (count_ == 5)
28 ACE_DEBUG ((LM_DEBUG,
29 ACE_TEXT ("Reseting interval for timer %d\n"),
30 timerID_));
32 // New interval is 10 ms.
33 ACE_Time_Value interval (0L, 1000L);
34 if (PTimer::instance ()->reset_interval (timerID_, interval) != -1)
35 ACE_ERROR_RETURN ((LM_ERROR,
36 ACE_TEXT ("%p\n"),
37 ACE_TEXT ("reset_interval")),
38 -1);
41 if (count_++ == 10)
43 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Canceling %d\n"),
44 timerID_));
45 PTimer::instance ()->cancel (this);
48 return 0;
51 void
52 PCB::setID (long timerID)
54 ACE_TRACE ("PCB::setID");
55 timerID_ = timerID;
58 long
59 PCB::getID () const
61 ACE_TRACE ("PCB::getID");
62 return timerID_;
65 int
66 PCB::handleClose ()
68 ACE_TRACE ("PCB::handleClose");
69 return 0;
72 int
73 PCB::handleCancel ()
75 ACE_TRACE ("PCB::handleCancel");
76 return 0;