summaryrefslogtreecommitdiff
path: root/ACE/examples/APG/Timers/PCB.cpp
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
commit7a52d43a162b23d9e85e7b955e9b2c8e9caf550e (patch)
tree66a84b20d47f2269d8bdc6e0323f338763424d3a /ACE/examples/APG/Timers/PCB.cpp
parent0e49389337be86641451a5c36c24bf742fe97523 (diff)
downloadATCD-7a52d43a162b23d9e85e7b955e9b2c8e9caf550e.tar.gz
Repo restructuring
Diffstat (limited to 'ACE/examples/APG/Timers/PCB.cpp')
-rw-r--r--ACE/examples/APG/Timers/PCB.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/ACE/examples/APG/Timers/PCB.cpp b/ACE/examples/APG/Timers/PCB.cpp
new file mode 100644
index 00000000000..d3401c65116
--- /dev/null
+++ b/ACE/examples/APG/Timers/PCB.cpp
@@ -0,0 +1,79 @@
+// $Id$
+
+#include "ace/Log_Msg.h"
+#include "PCB.h"
+#include "PTimerDispatcher.h"
+
+PCB::PCB() : count_(0)
+{
+ ACE_TRACE (ACE_TEXT ("PCB::PCB"));
+}
+
+PCB::~PCB()
+{
+}
+
+int PCB::handleEvent (const void *arg)
+{
+ ACE_TRACE (ACE_TEXT ("PCB::handle_timeout"));
+
+ const int *val = static_cast<const int*> (arg);
+ ACE_ASSERT ((*val) == timerID_);
+
+ ACE_UNUSED_ARG (val);
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Timer %d expiry handled by thread %t\n"),
+ timerID_));
+ if (count_ == 5)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Reseting interval for timer %d\n"),
+ timerID_));
+
+ // New interval is 10 ms.
+ ACE_Time_Value interval (0L, 1000L);
+ if (PTimer::instance ()->reset_interval (timerID_, interval) != -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("reset_interval")),
+ -1);
+ }
+
+ if (count_++ == 10)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Canceling %d\n"),
+ timerID_));
+ PTimer::instance ()->cancel (this);
+ }
+
+ return 0;
+}
+
+void
+PCB::setID (long timerID)
+{
+ ACE_TRACE (ACE_TEXT ("PCB::setID"));
+ timerID_ = timerID;
+}
+
+long
+PCB::getID (void) const
+{
+ ACE_TRACE (ACE_TEXT ("PCB::getID"));
+ return timerID_;
+}
+
+int
+PCB::handleClose (void)
+{
+ ACE_TRACE (ACE_TEXT ("PCB::handle_close"));
+ return 0;
+}
+
+int
+PCB::handleCancel (void)
+{
+ ACE_TRACE (ACE_TEXT ("PCB::handleCancel"));
+ return 0;
+}