summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-12 13:47:22 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-12 13:47:22 +0000
commitc973bc5304fbe126afce6f53681217c3999dc69b (patch)
tree40ac381360f461bbceb7b8a9f2122ed37998295c /examples
parent366784b9804535b5d17ee121f5783ab9a484f701 (diff)
downloadATCD-c973bc5304fbe126afce6f53681217c3999dc69b.tar.gz
removed unused constant NO_OF_IO_HANDLERS.
Diffstat (limited to 'examples')
-rw-r--r--examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp100
1 files changed, 49 insertions, 51 deletions
diff --git a/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp b/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
index 1344d52381e..b94a79a6d3e 100644
--- a/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
+++ b/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
@@ -3,7 +3,7 @@
// ============================================================================
// = LIBRARY
// examples
-//
+//
// = FILENAME
// Reactor_Timer_Queue_Test
//
@@ -13,7 +13,7 @@
// = AUTHOR
// Nanbor Wang <nw1@cs.wustl.edu> and
// Sergio Flores-Gaitan <sergio@cs.wustl.edu>
-//
+//
// ============================================================================
#include "ace/Thread_Manager.h"
@@ -24,44 +24,42 @@
#include "Driver.h"
#include "Reactor_Timer_Queue_Test.h"
-static const int NO_OF_IO_HANDLERS = 5;
-
-void
+void
Reactor_Timer_Handler::set_timer_id (long tid)
{
this->tid_ = tid;
}
-int
+int
Reactor_Timer_Handler::handle_timeout (const ACE_Time_Value &tv,
- const void *)
+ const void *)
{
// Macro to avoid "warning: unused parameter" type warning.
ACE_UNUSED_ARG (tv);
ACE_Time_Value txv = ACE_OS::gettimeofday ();
ACE_DEBUG ((LM_DEBUG, "\nTimer #%d fired at %d.%06d (%T)!\n",
- this->tid_, txv.sec (), txv.usec ()));
+ this->tid_, txv.sec (), txv.usec ()));
delete this;
return 0;
}
Input_Handler::Input_Handler (ACE_Timer_Queue *tq,
- Reactor_Timer_Queue_Test_Driver &timer_queue_driver)
+ Reactor_Timer_Queue_Test_Driver &timer_queue_driver)
: done_ (0),
driver_ (timer_queue_driver)
{
this->tq_ = tq;
}
-int
+int
Input_Handler::done (void)
{
return this->done_;
}
-
-int
+
+int
Input_Handler::schedule_timer (void *argument)
{
int delay = *(int *) argument;
@@ -71,27 +69,27 @@ Input_Handler::schedule_timer (void *argument)
th = new Reactor_Timer_Handler;
if (th != 0)
{
- tid = this->reactor ()->schedule_timer (th,
- 0,
- ACE_Time_Value (0, delay));
+ tid = this->reactor ()->schedule_timer (th,
+ 0,
+ ACE_Time_Value (0, delay));
if (tid == -1)
- ACE_DEBUG ((LM_DEBUG, "Unable to schedule timer\n"));
+ ACE_DEBUG ((LM_DEBUG, "Unable to schedule timer\n"));
else
- {
- ACE_DEBUG ((LM_DEBUG,
- "Timer #%d schedule to fire after %d usec from now.\n",
- tid,
- delay));
- th->set_timer_id (tid);
- }
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Timer #%d schedule to fire after %d usec from now.\n",
+ tid,
+ delay));
+ th->set_timer_id (tid);
+ }
}
else
ACE_ERROR_RETURN ((LM_ERROR, "not enough memory?\n"), -1);
return tid;
}
-
-int
+
+int
Input_Handler::cancel_timer (void *argument)
{
int id = *(int *) argument;
@@ -108,7 +106,7 @@ Input_Handler::shutdown_timer (void *argument)
ACE_DEBUG ((LM_DEBUG, "Shutting down event loop\n"));
return -1;
}
-
+
int
Input_Handler::list_timer (void *argument)
{
@@ -117,19 +115,19 @@ Input_Handler::list_timer (void *argument)
ACE_Timer_Queue_Iterator &iter = this->tq_->iter ();
ACE_DEBUG ((LM_DEBUG, "\n\nTimers in queue:\n"));
-
+
for (; ! iter.isdone (); iter.next ())
{
ACE_Timer_Node *tn = iter.item ();
ACE_DEBUG ((LM_DEBUG, "Timer #%d: %d.%06d\n",
- tn->get_timer_id (),
- tn->get_timer_value ().sec (),
- tn->get_timer_value ().usec ()));
+ tn->get_timer_id (),
+ tn->get_timer_value ().sec (),
+ tn->get_timer_value ().usec ()));
}
return 0;
}
-int
+int
Input_Handler::handle_input (ACE_HANDLE)
{
return driver_.get_next_request ();
@@ -140,48 +138,48 @@ Reactor_Timer_Queue_Test_Driver::Reactor_Timer_Queue_Test_Driver (void)
{
}
-int
+int
Reactor_Timer_Queue_Test_Driver::display_menu (void)
-{
- static char menu[] =
+{
+ static char menu[] =
"\n*****\n"
"1) Schedule timer <usec>\n"
"2) Cancel timer <id>\n"
"3) List all timers\n"
"4) Shutdown program\n"
"Enter selection:";
-
- ACE_DEBUG ((LM_DEBUG, "%s", menu));
+
+ ACE_DEBUG ((LM_DEBUG, "%s", menu));
return 0;
}
-int
+int
Reactor_Timer_Queue_Test_Driver::init (void)
{
typedef Command<Input_Handler, Input_Handler::ACTION> CMD;
// initialize <Command>s with their corresponding <Input_Handler> methods.
- ACE_NEW_RETURN (schedule_cmd_,
- CMD (thandler_, &Input_Handler::schedule_timer),
- -1);
-
+ ACE_NEW_RETURN (schedule_cmd_,
+ CMD (thandler_, &Input_Handler::schedule_timer),
+ -1);
+
ACE_NEW_RETURN (cancel_cmd_,
- CMD (thandler_, &Input_Handler::cancel_timer),
- -1);
+ CMD (thandler_, &Input_Handler::cancel_timer),
+ -1);
ACE_NEW_RETURN (list_cmd_,
- CMD (thandler_, &Input_Handler::list_timer),
- -1);
+ CMD (thandler_, &Input_Handler::list_timer),
+ -1);
ACE_NEW_RETURN (shutdown_cmd_,
- CMD (thandler_, &Input_Handler::shutdown_timer),
- -1);
+ CMD (thandler_, &Input_Handler::shutdown_timer),
+ -1);
ACE_Reactor::instance ()->set_timer_queue (&timer_queue_);
ACE::register_stdin_handler (&thandler_,
- ACE_Reactor::instance (),
+ ACE_Reactor::instance (),
ACE_Thread_Manager::instance ());
// print the menu of options.
@@ -192,9 +190,9 @@ Reactor_Timer_Queue_Test_Driver::init (void)
// run test was overrun due to the reactive way of handling input.
-int
-Reactor_Timer_Queue_Test_Driver::run_test (void)
-{
+int
+Reactor_Timer_Queue_Test_Driver::run_test (void)
+{
ACE_DEBUG ((LM_DEBUG, "TIMER TEST STARTED\n"));
this->init ();