diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-10-14 18:31:48 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-10-14 18:31:48 +0000 |
commit | 3e69c7ac4716b688b80b690a9131d91db2f36f4d (patch) | |
tree | a03bcc49d6ed22d0962b2b17ef016c18a82b7ce5 /examples/Timer_Queue | |
parent | 21069bed09835ebe94cef30450d9945302c02458 (diff) | |
download | ATCD-3e69c7ac4716b688b80b690a9131d91db2f36f4d.tar.gz |
(main): removed declaration of unused args "argc" and "argv". And, updated template instantiations.
Diffstat (limited to 'examples/Timer_Queue')
-rw-r--r-- | examples/Timer_Queue/Thread_Timer_Queue_Test.cpp | 172 |
1 files changed, 95 insertions, 77 deletions
diff --git a/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp b/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp index 01dfa82dd84..a0441dce602 100644 --- a/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp +++ b/examples/Timer_Queue/Thread_Timer_Queue_Test.cpp @@ -4,17 +4,17 @@ // // = LIBRARY // examples -// +// // = FILENAME // Thread_Timer_Queue_Test.cpp // // = DESCRIPTION -// This test exercises the <ACE_Thread_Timer_Queue_Adapter> +// This test exercises the <ACE_Thread_Timer_Queue_Adapter> // using an <ACE_Timer_Heap>. // // = AUTHORS // Carlos O'Ryan and Douglas C. Schmidt -// +// // ============================================================================ #include "ace/Task.h" @@ -23,27 +23,27 @@ // These typedefs ensure that we use the minimal amount of locking // necessary. -typedef ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex> - Upcall; +typedef ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex> + Upcall; typedef ACE_Timer_Heap_T<ACE_Event_Handler *, - ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, - ACE_Null_Mutex> - Timer_Heap; + ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, + ACE_Null_Mutex> + Timer_Heap; typedef ACE_Timer_Heap_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, - ACE_Null_Mutex> + ACE_Null_Mutex> Timer_Heap_Iterator; typedef ACE_Thread_Timer_Queue_Adapter<Timer_Heap> Thread_Timer_Queue; -class Handler : public ACE_Event_Handler +class Handler : public ACE_Event_Handler // = TITLE // This class implements a simple Event_Handler, // // = DESCRIPTION // The <handle_timeout> hook method justs printouts the current // time, delete this and prints the delay on the twhen it is - // expired. + // expired. { public: Handler (const ACE_Time_Value &expiration_time); @@ -54,7 +54,7 @@ public: // messages. virtual int handle_timeout (const ACE_Time_Value ¤t_time, - const void *arg); + const void *arg); // Call back hook. virtual int cancelled (void); @@ -120,7 +120,7 @@ Handler::~Handler (void) { } -void +void Handler::set_id (int id) { this->id_ = id; @@ -128,20 +128,20 @@ Handler::set_id (int id) // This is the method invoked when the Timer expires. -int +int Handler::handle_timeout (const ACE_Time_Value ¤t_time, - const void *) + const void *) { ACE_Time_Value delay = current_time - this->expires_; // No need to protect this printf is always called from a Async safe // point. ACE_OS::printf ("\nexpiring timer %d at %u.%07.7u secs\n" - "\tthere was a %u.%07.7u secs delay\n", - this->id_, - current_time.sec (), - current_time.usec (), - delay.sec (), delay.usec ()); + "\tthere was a %u.%07.7u secs delay\n", + this->id_, + current_time.sec (), + current_time.usec (), + delay.sec (), delay.usec ()); // Notice this delete is protected. delete this; @@ -150,7 +150,7 @@ Handler::handle_timeout (const ACE_Time_Value ¤t_time, // The handler was cancelled, so we must delete this. -int +int Handler::cancelled (void) { delete this; @@ -163,7 +163,7 @@ Input_Task::Input_Task (Thread_Timer_Queue *queue) { } -int +int Input_Task::svc (void) { for (;;) @@ -175,10 +175,10 @@ Input_Task::svc (void) ACE_OS::fflush (stdout); if (ACE_OS::read (ACE_STDIN, buf, sizeof buf) <= 0) - break; + break; if (parse_commands (buf) < 0) - break; + break; } this->queue_->deactivate (); @@ -197,7 +197,7 @@ Input_Task::add_timer (u_long useconds) ACE_NEW_RETURN (h, Handler (expire_at), -1); int id = queue_->schedule (h, 0, expire_at); - + if (id == -1) ACE_ERROR_RETURN ((LM_ERROR, "schedule failed"), -1); @@ -210,13 +210,13 @@ Input_Task::add_timer (u_long useconds) return 0; } -void +void Input_Task::cancel_timer (int id) { this->queue_->cancel (id); } -void +void Input_Task::dump (void) { ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->queue_->lock ()); @@ -231,17 +231,17 @@ Input_Task::dump (void) ACE_DEBUG ((LM_DEBUG, "end dumping timer queue\n")); } -void +void Input_Task::usage (void) const { ACE_OS::printf ("Usage:\n" - "1 <microseconds>: setups a new timer\n" - "2 <timerid>: removes a timer\n" - "3 : prints timer queue\n" - "4 : exit\n"); + "1 <microseconds>: setups a new timer\n" + "2 <timerid>: removes a timer\n" + "3 : prints timer queue\n" + "4 : exit\n"); } -int +int Input_Task::parse_commands (const char *buf) { int option; @@ -258,29 +258,29 @@ Input_Task::parse_commands (const char *buf) { case 1: // Install a new timer. { - u_long useconds; - // We just reread the option, this simplies parsing (since - // sscanf can do it for us.) - if (::sscanf (buf, "%d %lu", &option, &useconds) < 2) - { - this->usage (); - return 0; - } - if (this->add_timer (useconds) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "new timer failed"), -1); + u_long useconds; + // We just reread the option, this simplies parsing (since + // sscanf can do it for us.) + if (::sscanf (buf, "%d %lu", &option, &useconds) < 2) + { + this->usage (); + return 0; + } + if (this->add_timer (useconds) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", "new timer failed"), -1); } break; // Cancel an existing timer. case 2: { - u_long id; - // We just reread the option, this simplies parsing (since - // sscanf can do it for us.) - if (::sscanf (buf, "%d %lu", &option, &id) < 2) - { - this->usage (); - return 0; - } - this->cancel_timer (id); + u_long id; + // We just reread the option, this simplies parsing (since + // sscanf can do it for us.) + if (::sscanf (buf, "%d %lu", &option, &id) < 2) + { + this->usage (); + return 0; + } + this->cancel_timer (id); } break; @@ -299,19 +299,19 @@ Input_Task::parse_commands (const char *buf) return 0; } -int -main (int argc, char* argv[]) +int +main (int, char *[]) { Thread_Timer_Queue tq; Input_Task input_task (&tq); - + if (input_task.activate () == -1) ACE_ERROR_RETURN ((LM_ERROR, "cannot activate input task"), -1); - + if (tq.activate () == -1) ACE_ERROR_RETURN ((LM_ERROR, "cannot activate timer queue"), -1); - + if (ACE_Thread_Manager::instance ()->wait () == -1) ACE_ERROR_RETURN ((LM_ERROR, "wait on Thread_Manager failed"),-1); @@ -319,27 +319,45 @@ main (int argc, char* argv[]) } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -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>; + template class ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>; + template class ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex>; + 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> +# 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> +# pragma instantiate ACE_Timer_Queue_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex> +# pragma instantiate ACE_Timer_Queue_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Null_Mutex>, ACE_Null_Mutex> +# pragma instantiate ACE_Thread_Timer_Queue_Adapter<Timer_Heap> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ -#if !defined(ACE_MT_SAFE) - -// These templates will specialized in liACE.* if the platforms does -// not define ACE_MT_SAFE. - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -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> - +#if defined (ACE_MT_SAFE) +# if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + template class ACE_Condition<ACE_Thread_Mutex>; + template class ACE_Thread_Condition<ACE_Thread_Mutex>; +# elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +# pragma instantiate ACE_Condition<ACE_Thread_Mutex> +# pragma instantiate ACE_Thread_Condition<ACE_Thread_Mutex> +# endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ +#else /* ! ACE_MT_SAFE */ + + // These templates will specialized in liACE.* if the platforms does + // not define ACE_MT_SAFE. + +# if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + 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 */ +#endif /* ! ACE_MT_SAFE */ |