summaryrefslogtreecommitdiff
path: root/examples/Timer_Queue
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-10-21 06:20:20 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-10-21 06:20:20 +0000
commitc6840f69f0347119bdabbbf6bf09bf5fe67a4f15 (patch)
tree4b884b1cb6fd50a4955fc40ce5695f2e24a370f2 /examples/Timer_Queue
parent8978ecc049a071f96d820c1bbe928e540a9322b4 (diff)
downloadATCD-c6840f69f0347119bdabbbf6bf09bf5fe67a4f15.tar.gz
*** empty log message ***
Diffstat (limited to 'examples/Timer_Queue')
-rw-r--r--examples/Timer_Queue/Async_Timer_Queue_Test.cpp8
-rw-r--r--examples/Timer_Queue/Async_Timer_Queue_Test.h12
-rw-r--r--examples/Timer_Queue/README5
-rw-r--r--examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp13
-rw-r--r--examples/Timer_Queue/Reactor_Timer_Queue_Test.h49
-rw-r--r--examples/Timer_Queue/Thread_Timer_Queue_Test.cpp11
-rw-r--r--examples/Timer_Queue/main_async.cpp3
-rw-r--r--examples/Timer_Queue/main_reactor.cpp3
-rw-r--r--examples/Timer_Queue/main_thread.cpp3
9 files changed, 54 insertions, 53 deletions
diff --git a/examples/Timer_Queue/Async_Timer_Queue_Test.cpp b/examples/Timer_Queue/Async_Timer_Queue_Test.cpp
index bc07c931a4e..4979cd4b537 100644
--- a/examples/Timer_Queue/Async_Timer_Queue_Test.cpp
+++ b/examples/Timer_Queue/Async_Timer_Queue_Test.cpp
@@ -129,7 +129,7 @@ Async_Timer_Queue::cancel (long timer_id)
delete (ACE_Event_Handler *) act;
}
-// Schedule timer hook method. This method is called from the driver.
+// Schedule timer hook method. This method is called from the driver.
int
Async_Timer_Queue::schedule_timer (void *argument)
@@ -155,8 +155,8 @@ Async_Timer_Queue::cancel_timer (void *argument)
return 0;
}
-// Dummy list timer hook method. The listing of timers is done from
-// a signal handler using SIGINT, not from the driver.
+// Dummy list timer hook method. The listing of timers is done from a
+// signal handler using SIGINT, not from the driver.
int
Async_Timer_Queue::list_timer (void *argument)
@@ -258,7 +258,7 @@ Async_Timer_Queue_Test_Driver::init (void)
{
typedef Command<Async_Timer_Queue, Async_Timer_Queue::ACTION> COMMAND;
- // initialize <Command> objects with their corresponding <Input_Task> methods.
+ // Initialize <Command> objects with their corresponding <Input_Task> methods.
ACE_NEW_RETURN (schedule_cmd_,
COMMAND (*Async_Timer_Queue::instance (),
&Async_Timer_Queue::schedule_timer),
diff --git a/examples/Timer_Queue/Async_Timer_Queue_Test.h b/examples/Timer_Queue/Async_Timer_Queue_Test.h
index 8439aa9c45e..40002b9b82e 100644
--- a/examples/Timer_Queue/Async_Timer_Queue_Test.h
+++ b/examples/Timer_Queue/Async_Timer_Queue_Test.h
@@ -63,16 +63,20 @@ public:
// Dump the contents of the queue.
int schedule_timer (void *argument);
- // hook method to schedule a timer. Called from <Timer_Queue_Test_Driver>
+ // hook method to schedule a timer. Called from
+ // <Timer_Queue_Test_Driver>
int cancel_timer (void *argument);
- // hook method to cancel a timer. Called from <Timer_Queue_Test_Driver>
+ // hook method to cancel a timer. Called from
+ // <Timer_Queue_Test_Driver>
int list_timer (void *argument);
- // hook method to list timers. Called from <Timer_Queue_Test_Driver>
+ // hook method to list timers. Called from
+ // <Timer_Queue_Test_Driver>
int shutdown_timer (void *argument);
- // hook method to exit the timer queue. Called from <Timer_Queue_Test_Driver>
+ // hook method to exit the timer queue. Called from
+ // <Timer_Queue_Test_Driver>
private:
Async_Timer_Queue (ACE_Sig_Set *);
diff --git a/examples/Timer_Queue/README b/examples/Timer_Queue/README
index f09ee4d45cc..3cf6ec1b75b 100644
--- a/examples/Timer_Queue/README
+++ b/examples/Timer_Queue/README
@@ -1,7 +1,8 @@
This directory contains several examples that illustrate how to use
various concurrency mechanisms to schedule and handle timer-based
-events. All programs are interactive. You can schedule or cancel
-time events and list all the timers that are waiting to be triggered.
+events. All programs are interactive and utilize a common timer queue
+test framework. You can schedule or cancel time events and list all
+the timers that are waiting to be triggered.
The tests include:
diff --git a/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp b/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
index c8283b09ffb..ad444ee3f0a 100644
--- a/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
+++ b/examples/Timer_Queue/Reactor_Timer_Queue_Test.cpp
@@ -25,7 +25,6 @@
#include "Reactor_Timer_Queue_Test.h"
static const int NO_OF_IO_HANDLERS = 5;
-#define REACTOR ACE_Reactor::instance ()
void
Reactor_Timer_Handler::set_timer_id (long tid)
@@ -35,7 +34,7 @@ Reactor_Timer_Handler::set_timer_id (long tid)
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);
@@ -48,7 +47,8 @@ Reactor_Timer_Handler::handle_timeout (const ACE_Time_Value &tv,
return 0;
}
-Input_Handler::Input_Handler (ACE_Timer_Queue *tq, Reactor_Timer_Queue_Test_Driver &timer_queue_driver)
+Input_Handler::Input_Handler (ACE_Timer_Queue *tq,
+ Reactor_Timer_Queue_Test_Driver &timer_queue_driver)
: done_ (0),
driver_ (timer_queue_driver)
{
@@ -178,9 +178,10 @@ Reactor_Timer_Queue_Test_Driver::init (void)
COMMAND (thandler_, &Input_Handler::shutdown_timer),
-1);
- REACTOR->set_timer_queue (&timer_queue_);
+ ACE_Reactor::instance ()->set_timer_queue (&timer_queue_);
- ACE::register_stdin_handler (&thandler_, REACTOR,
+ ACE::register_stdin_handler (&thandler_,
+ ACE_Reactor::instance (),
ACE_Thread_Manager::instance ());
// print the menu of options.
@@ -200,7 +201,7 @@ Reactor_Timer_Queue_Test_Driver::run_test (void)
// Run until we say stop.
while (thandler_.done () == 0)
- REACTOR->handle_events ();
+ ACE_Reactor::instance ()->handle_events ();
ACE_DEBUG ((LM_DEBUG, "TIMER TEST ENDED\n"));
return 0;
diff --git a/examples/Timer_Queue/Reactor_Timer_Queue_Test.h b/examples/Timer_Queue/Reactor_Timer_Queue_Test.h
index a1ea8fd147c..abee5e95843 100644
--- a/examples/Timer_Queue/Reactor_Timer_Queue_Test.h
+++ b/examples/Timer_Queue/Reactor_Timer_Queue_Test.h
@@ -30,8 +30,8 @@ class Reactor_Timer_Queue_Test_Driver;
class Input_Handler : public ACE_Event_Handler
// = TITLE
- // Implements the handler to be called for input events. Also has
- // the logic to handle the different timer queue operations (i.e.,
+ // Implements the handler to be called for input events. Also has
+ // the logic to handle the different timer queue operations (i.e.,
// schedule, cancel, list, shutdown).
//
// = DESCRIPTION
@@ -45,25 +45,26 @@ public:
Input_Handler (ACE_Timer_Queue *tq,
Reactor_Timer_Queue_Test_Driver &timer_queue_driver);
// Sets <done_> flag to 0, <driver_> to <timer_queue_driver> and
- // timer queue <tq_> to <tq>
+ // timer queue <tq_> to <tq>
int handle_input (ACE_HANDLE);
// Hook method for the <ACE_Reactor> to call whenever there is input
// ready to be read.
int done (void);
- // returns the value for <done_> that indicates whether we are exiting
- // the program.A value of 0 indicates that we are NOT done, 1 otherwise.
+ // returns the value for <done_> that indicates whether we are
+ // exiting the program.A value of 0 indicates that we are NOT done,
+ // 1 otherwise.
// = Hook methods to be called from <Reactor_Timer_Queue_Test_Driver>
int schedule_timer (void *argument);
- // schedule a timer. The (void *) will be mapped to the delay parameter
- // for the timer queue schedule method.
+ // Schedule a timer. The (void *) will be mapped to the delay
+ // parameter for the timer queue schedule method.
int cancel_timer (void *argument);
- // cancel a timer. The (void *) will be mapped to the ID of the timer
- // beiing cancelled.
+ // Cancel a timer. The (void *) will be mapped to the ID of the
+ // timer beiing cancelled.
int list_timer (void *argument);
// Dump the timers in the queue. The argument is ignored.
@@ -74,20 +75,21 @@ public:
private:
ACE_Timer_Queue *tq_;
- // Keep a pointer to the timer queue we are using so we can
- // traverse the queue.
+ // Keep a pointer to the timer queue we are using so we can traverse
+ // the queue.
int done_;
// Flag used to close down program.
Reactor_Timer_Queue_Test_Driver &driver_;
- // Test driver. Used to call hook methods that are common code for all
- // drivers.
+ // Test driver. Used to call hook methods that are common code for
+ // all drivers.
};
class Reactor_Timer_Queue_Test_Driver : public Timer_Queue_Test_Driver <ACE_Timer_Heap, Input_Handler, Input_Handler::ACTION>
// = TITLE
- // Implements a test driver for a reactive timer queue using <ACE_Reactor>.
+ // Implements a test driver for a reactive timer queue using
+ // <ACE_Reactor>.
//
// = DESCRIPTION
// This class implements the logic to test the reactor
@@ -95,18 +97,19 @@ class Reactor_Timer_Queue_Test_Driver : public Timer_Queue_Test_Driver <ACE_Time
{
public:
Reactor_Timer_Queue_Test_Driver (void);
- // sets the input handler <thandler_> with <timer_queue_> from the
+ // Sets the input handler <thandler_> with <timer_queue_> from the
// <Timer_Queue_Test_Driver> class and a reference to "this", so the
- // input handler can call hook methods from the driver. Such methods are
- // the common factored out code from other implementations of timer queues.
+ // input handler can call hook methods from the driver. Such
+ // methods are the common factored out code from other
+ // implementations of timer queues.
virtual int display_menu (void);
- // prints the menu of options.
+ // Prints the menu of options.
virtual int init (void);
- // Sets the timer queue that the REACTOR will use; registers the stdin
- // input handler with the REACTOR and sets the <Command>s that the
- // <Timer_Queue_Test_Driver> will execute().
+ // Sets the timer queue that the REACTOR will use; registers the
+ // stdin input handler with the REACTOR and sets the <Command>s that
+ // the <Timer_Queue_Test_Driver> will execute().
virtual int run_test (void);
// Main entry point to the test driver implementation.
@@ -123,8 +126,8 @@ class Reactor_Timer_Handler : public ACE_Event_Handler
public:
virtual int handle_timeout (const ACE_Time_Value &tv,
const void *);
- // hook method that is called by the reactor when a timer
- // expires. It prints the timer ID and the time it expired.
+ // Hook method that is called by the reactor when a timer expires.
+ // It prints the timer ID and the time it expired.
void set_timer_id (long tid);
// Sets the timer id for this handler <tid_> to <tid>
diff --git a/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp b/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp
index 24f7c5f7110..838b4f01681 100644
--- a/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp
+++ b/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp
@@ -248,12 +248,8 @@ Thread_Timer_Queue_Test_Driver::init (void)
return 0;
}
-
-
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Thread_Timer_Queue_Adapter<Timer_Heap>;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Thread_Timer_Queue_Adapter<Timer_Heap>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
#if !defined(ACE_MT_SAFE)
@@ -266,12 +262,5 @@ template class ACE_Thread_Timer_Queue_Adapter<Timer_Heap>;
template class ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>;
template class ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>;
template class ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>;
-
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-
-#pragma instantiate ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>
-#pragma instantiate ACE_Timer_Heap_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>
-#pragma instantiate ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>
-
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
#endif /* ACE_MT_SAFE */
diff --git a/examples/Timer_Queue/main_async.cpp b/examples/Timer_Queue/main_async.cpp
index 1447257e2de..9c46e4293c2 100644
--- a/examples/Timer_Queue/main_async.cpp
+++ b/examples/Timer_Queue/main_async.cpp
@@ -31,7 +31,8 @@ typedef Timer_Queue_Test_Driver<Async_Timer_Queue*,
int
main (int, char *[])
{
- // Auto ptr ensures that the driver memory is released automatically.
+ // Auto ptr ensures that the driver memory is released
+ // automatically.
auto_ptr <ASYNC_TIMER_QUEUE_TEST_DRIVER> driver;
ASYNC_TIMER_QUEUE_TEST_DRIVER *tqtd;
diff --git a/examples/Timer_Queue/main_reactor.cpp b/examples/Timer_Queue/main_reactor.cpp
index 724a5da52a1..cf5584e968d 100644
--- a/examples/Timer_Queue/main_reactor.cpp
+++ b/examples/Timer_Queue/main_reactor.cpp
@@ -31,7 +31,8 @@ typedef Timer_Queue_Test_Driver <ACE_Timer_Heap,
int
main (int, char *[])
{
- // Auto ptr ensures that the driver memory is released automatically.
+ // Auto ptr ensures that the driver memory is released
+ // automatically.
auto_ptr <REACTOR_TIMER_QUEUE_TEST_DRIVER> driver;
REACTOR_TIMER_QUEUE_TEST_DRIVER *tqtd;
diff --git a/examples/Timer_Queue/main_thread.cpp b/examples/Timer_Queue/main_thread.cpp
index 9d16c6cebd8..b72f0fe7088 100644
--- a/examples/Timer_Queue/main_thread.cpp
+++ b/examples/Timer_Queue/main_thread.cpp
@@ -31,7 +31,8 @@ typedef Timer_Queue_Test_Driver<Thread_Timer_Queue,
int
main (int, char *[])
{
- // Auto ptr ensures that the driver memory is released automatically.
+ // Auto ptr ensures that the driver memory is released
+ // automatically.
auto_ptr <THREAD_TIMER_QUEUE_TEST_DRIVER> driver;
THREAD_TIMER_QUEUE_TEST_DRIVER *tqtd;