diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-10-12 22:22:31 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-10-12 22:22:31 +0000 |
commit | a5871ecd93cff36516638a5a1e028bc134c54354 (patch) | |
tree | 81a6d84197f45df4e3d1dd8f649f5ca412639ce7 | |
parent | a033a40ff39c2172b517fa6413ea4902f6cd20c2 (diff) | |
download | ATCD-a5871ecd93cff36516638a5a1e028bc134c54354.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-97b | 35 | ||||
-rw-r--r-- | TAO/ChangeLog-98c | 23 | ||||
-rw-r--r-- | TAO/tao/client_factory.h | 12 | ||||
-rw-r--r-- | TAO/tao/client_factory.i | 2 | ||||
-rw-r--r-- | TAO/tao/corba.h | 1 | ||||
-rw-r--r-- | TAO/tao/default_client.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/default_client.h | 8 | ||||
-rw-r--r-- | TAO/tao/default_server.cpp | 9 | ||||
-rw-r--r-- | TAO/tao/giop.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/orbobj.cpp | 78 | ||||
-rw-r--r-- | TAO/tao/orbobj.h | 46 | ||||
-rw-r--r-- | ace/Dump.h | 1 | ||||
-rw-r--r-- | ace/High_Res_Timer.cpp | 40 | ||||
-rw-r--r-- | ace/High_Res_Timer.i | 6 | ||||
-rw-r--r-- | ace/OS.cpp | 16 | ||||
-rw-r--r-- | ace/OS.h | 4 | ||||
-rw-r--r-- | ace/OS.i | 28 | ||||
-rw-r--r-- | ace/Profile_Timer.cpp | 31 | ||||
-rw-r--r-- | ace/Timer_List.cpp | 2 | ||||
-rw-r--r-- | ace/config-tandem.h | 1 | ||||
-rw-r--r-- | examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp | 8 | ||||
-rw-r--r-- | examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h | 10 | ||||
-rw-r--r-- | tests/Priority_Reactor_Test.cpp | 15 |
23 files changed, 231 insertions, 149 deletions
diff --git a/ChangeLog-97b b/ChangeLog-97b index 90e82a868dd..7c44bfc4373 100644 --- a/ChangeLog-97b +++ b/ChangeLog-97b @@ -1,18 +1,21 @@ -Sun Oct 12 16:45:47 1997 Carlos O'Ryan <coryan@macarena.cs.wustl.edu> +Sun Oct 12 16:53:32 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> - * ace/Sched_Params.h: - Added some comments. + * ace/examples/Service_Configurator/IPC-tests/server: Reformatted + and recommented the code a bit. - * examples/Timer_Queue/Thread_Timer_Queue_Test.cpp: - Added some comments and template specializations. + * ace/OS: Added 3 new ACE #defines: -Sun Oct 12 16:22:06 1997 Carlos O'Ryan <coryan@macarena.cs.wustl.edu> + #define ACE_ONE_SECOND_IN_MSECS 1000L + #define ACE_ONE_SECOND_IN_USECS 1000000L + #define ACE_ONE_SECOND_IN_NSECS 1000000000L - * examples/Naming/Makefile: - There is no need to set LDLIBS to add local object files - anymore, using FILES is enough. + This is much easier to read than trying to keep track of the + 000s! Then, replaced all uses of the original values with the + new symbolic constants. -Sun Oct 12 14:18:12 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + * ace/Timer_List.cpp: Removed an explicit template instantiation + of ACE_Async_Timer_Queue_Adapter<>. Why was it here in the + first place? * ace: Created a new group of Timer_Queue_Adapters files and moved the Async and Thread adapters into this file. This reduces the @@ -32,6 +35,18 @@ Sun Oct 12 14:18:12 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> * examples/Makefile (DIRS): Added Timer_Queue to the list of DIRS to build. +Sun Oct 12 16:45:47 1997 Carlos O'Ryan <coryan@macarena.cs.wustl.edu> + + * ace/Sched_Params.h: + Added some comments. + + * examples/Timer_Queue/Thread_Timer_Queue_Test.cpp: + Added some comments and template specializations. + + * examples/Naming/Makefile: + There is no need to set LDLIBS to add local object files + anymore, using FILES is enough. + Sun Oct 12 03:35:37 1997 Nanbor Wang <nw1@cumbia.cs.wustl.edu> * ace/ACE.cpp (register_stdin_handler): Must register the reactor diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 1947d496bd3..a2de007edbe 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,26 @@ +Sun Oct 12 15:38:35 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + + * tao/orbobj.cpp (perform_work): Updated the run() and perform_work() + methods to take optional ACE_Time_Value *'s and to return error + flags if things go wrong. + + * tao/orbobj.h (CORBA_ORB): Changed the set_up_for_listening() + call to open(), which is more consistent with other usage in + ACE/TAO. + + * tao/orbobj: Changed the name client_acceptor_ to peer_acceptor_ + to reflect the fact that the connection model is more generic + than the notion of client/server interactions (which really take + place as the result of particular communication roles). + + * tao/corba.h: Moved the order of #includes around so that + "connect.h" is included before "client_factory.h" + + * tao/connect.h: Moved the typedef of the ACE_Strategy_Connector<> + from the TAO_Client_Strategy_Factory into the global space and + renamed it TAO_CONNECTOR file so that it will be equivalent with + the TAO_ACCEPTOR. + Thu Oct 9 23:17:37 1997 Douglas C. Schmidt <schmidt@merengue.cs.wustl.edu> * tao/giop.cpp (invoke): If an error occurs, make sure to mark the diff --git a/TAO/tao/client_factory.h b/TAO/tao/client_factory.h index 9b861ea1f11..ce00e786607 100644 --- a/TAO/tao/client_factory.h +++ b/TAO/tao/client_factory.h @@ -31,8 +31,8 @@ class TAO_Client_Connection_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> // = TITLE - // <Svc_Handler> used on the client side and returned - // by the <TAO_Client_Factory::CONNECTOR>. + // <Svc_Handler> used on the client side and returned by the + // <TAO_CONNECTOR>. // @@ Should this be in here or in the default_client.*? { public: @@ -55,6 +55,10 @@ private: // True value indicates that something is using this handler. }; +// This is equivalent to the TAO_ACCEPTOR. +typedef ACE_Strategy_Connector<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR> + TAO_CONNECTOR; + class TAO_Client_Strategy_Factory : public ACE_Service_Object // = TITLE // Abstract factory used by the client to manufacture various @@ -69,8 +73,6 @@ public: // Destructor // = Client-side strategy types. - typedef ACE_Strategy_Connector<TAO_Client_Connection_Handler, ACE_SOCK_CONNECTOR> - CONNECTOR; typedef ACE_NOOP_Creation_Strategy<TAO_Client_Connection_Handler> NULL_CREATION_STRATEGY; @@ -82,7 +84,7 @@ public: virtual CONCURRENCY_STRATEGY *concurrency_strategy (void); #endif /* TAO_HAS_CLIENT_CONCURRENCY */ - virtual CONNECTOR *connector (void); + virtual TAO_CONNECTOR *connector (void); // Return a pointer to a connector using appropriate strategies. }; diff --git a/TAO/tao/client_factory.i b/TAO/tao/client_factory.i index d6809f0fcee..18024d7a668 100644 --- a/TAO/tao/client_factory.i +++ b/TAO/tao/client_factory.i @@ -15,7 +15,7 @@ TAO_Client_Connection_Handler::in_use (CORBA::Boolean flag) in_use_ = flag; } -ACE_INLINE TAO_Client_Strategy_Factory::CONNECTOR * +ACE_INLINE TAO_CONNECTOR * TAO_Client_Strategy_Factory::connector (void) { return 0; diff --git a/TAO/tao/corba.h b/TAO/tao/corba.h index 90f53e346a2..32b14c79208 100644 --- a/TAO/tao/corba.h +++ b/TAO/tao/corba.h @@ -70,7 +70,6 @@ #include "tao/boa.h" #include "tao/params.h" -//#include "tao/factories.h" #include "tao/client_factory.h" #include "tao/client_factory.h" #include "tao/server_factory.h" diff --git a/TAO/tao/default_client.cpp b/TAO/tao/default_client.cpp index b0d45a2bb5f..5affd8ab1ca 100644 --- a/TAO/tao/default_client.cpp +++ b/TAO/tao/default_client.cpp @@ -48,7 +48,7 @@ TAO_Default_Client_Strategy_Factory::init (int argc, char *argv[]) return this->parse_args (argc, argv); } -TAO_Client_Strategy_Factory::CONNECTOR * +TAO_CONNECTOR * TAO_Default_Client_Strategy_Factory::connector (void) { return &this->connector_; diff --git a/TAO/tao/default_client.h b/TAO/tao/default_client.h index 7e304157cc3..6e8ec64c99f 100644 --- a/TAO/tao/default_client.h +++ b/TAO/tao/default_client.h @@ -52,7 +52,7 @@ public: ACE_SYNCH_RW_MUTEX> CACHED_CONNECT_STRATEGY; - virtual TAO_Client_Strategy_Factory::CONNECTOR *connector (void); + virtual TAO_CONNECTOR *connector (void); // Return a pointer to a connector using appropriate strategies. // = Service Configurator hooks. @@ -64,8 +64,6 @@ public: private: - // @@ Chris, please add comments to these members. - #if defined (TAO_HAS_CLIENT_CONCURRENCY) // @@ Chris, shouldn't this always be "potentially" the case, even // if a client didn't want to use it? @@ -73,7 +71,9 @@ private: CONCURRENCY_STRATEGY *concurrency_strategy_; #endif /* TAO_HAS_CLIENT_CONCURRENCY */ - CONNECTOR connector_; + // @@ Chris, please add comments to these members. + + TAO_CONNECTOR connector_; NULL_CREATION_STRATEGY null_creation_strategy_; diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp index 9e85cbde5b0..3200a1dbddf 100644 --- a/TAO/tao/default_server.cpp +++ b/TAO/tao/default_server.cpp @@ -107,11 +107,12 @@ TAO_Default_Server_Strategy_Factory::tokenize (char *flag_string) int TAO_Default_Server_Strategy_Factory::init (int argc, char *argv[]) { - TAO_ORB_Core *orb_core = TAO_ORB_Core_instance(); + TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); - if ((this->parse_args (argc, argv) == 0) - && (reactive_strategy_.open (orb_core->reactor ()) == 0) - && (threaded_strategy_.open (orb_core->thr_mgr (), this->thread_flags_) == 0)) + if (this->parse_args (argc, argv) == 0 + && reactive_strategy_.open (orb_core->reactor ()) == 0 + && threaded_strategy_.open (orb_core->thr_mgr (), + this->thread_flags_) == 0) return 0; else return -1; diff --git a/TAO/tao/giop.cpp b/TAO/tao/giop.cpp index 2098fbc1cc6..a3bf37ca6f7 100644 --- a/TAO/tao/giop.cpp +++ b/TAO/tao/giop.cpp @@ -635,7 +635,7 @@ TAO_GIOP_Invocation::start (CORBA::Environment &env) // Get a reference to the client connector // TAO_Client_Factory::CONNECTOR* con = 0; - TAO_Client_Strategy_Factory::CONNECTOR* con = 0; + TAO_CONNECTOR *con = 0; con = orb->client_factory ()->connector (); // Determine the object key and the address to which we'll need a diff --git a/TAO/tao/orbobj.cpp b/TAO/tao/orbobj.cpp index 94091fb0e33..10703aa7500 100644 --- a/TAO/tao/orbobj.cpp +++ b/TAO/tao/orbobj.cpp @@ -49,7 +49,7 @@ DEFINE_GUID (IID_STUB_Object, 0xa201e4c7, 0xf258, 0x11ce, 0x95, 0x98, 0x0, 0x0, 0xc0, 0x7c, 0xa8, 0x98); CORBA_ORB::CORBA_ORB (void) - : set_up_for_listening_called_(CORBA::B_FALSE), + : open_called_(CORBA::B_FALSE), client_factory_ (0), client_factory_from_service_config_ (CORBA::B_FALSE), server_factory_ (0), @@ -72,27 +72,30 @@ CORBA_ORB::~CORBA_ORB (void) // assert (refcount_ == 0); } -void -CORBA_ORB::set_up_for_listening (void) +int +CORBA_ORB::open (void) { - if (this->set_up_for_listening_called_) - return; + if (this->open_called_) + return -1; - this->set_up_for_listening_called_ = CORBA::B_TRUE; + this->open_called_ = CORBA::B_TRUE; TAO_Server_Strategy_Factory *f = this->server_factory (); // Initialize the endpoint ... or try! - if (this->client_acceptor_.open (this->params()->addr (), - TAO_ORB_Core_instance()->reactor(), - f->creation_strategy (), - f->accept_strategy (), - f->concurrency_strategy (), - f->scheduling_strategy ()) == -1) + if (this->peer_acceptor_.open (this->params()->addr (), + TAO_ORB_Core_instance()->reactor(), + f->creation_strategy (), + f->accept_strategy (), + f->concurrency_strategy (), + f->scheduling_strategy ()) == -1) // @@ CJC Need to return an error somehow!! Maybe set do_exit? - ; + return -1; + + if (this->peer_acceptor_.acceptor ().get_local_addr (this->addr_) == -1) + return -1; - client_acceptor_.acceptor ().get_local_addr (addr_); + return 0; } TAO_Client_Strategy_Factory * @@ -506,30 +509,47 @@ CORBA_ORB::BOA_init (int &argc, return rp; } -void -CORBA_ORB::perform_work (void) +int +CORBA_ORB::perform_work (ACE_Time_Value *tv) { - TAO_ORB_Core_instance ()->reactor ()->handle_events (); + return TAO_ORB_Core_instance ()->reactor ()->handle_events (tv); } -void -CORBA_ORB::run (void) +int +CORBA_ORB::run (ACE_Time_Value *tv) { - ACE_Reactor* r = TAO_ORB_Core_instance ()->reactor (); + ACE_Reactor *r = TAO_ORB_Core_instance ()->reactor (); // This method should only be called by servers, so now we set up // for listening! - this->set_up_for_listening (); + if (this->open () == -1) + return -1; - while (1) - { - int result = r->handle_events (); + // Loop "forever" handling client requests. + + for (;;) + switch (r->handle_events (tv)) + { + case 0: // Timed out, so we return to caller. + return 0; + /* NOTREACHED */ + case -1: // Something else has gone wrong, so return to caller. + return -1; + /* NOTREACHED */ + default: // Some handlers were dispatched, so keep on processing + // requests until we're told to shutdown . +#if 0 + // @@ How can we figure out how to get the right POA pointer + // to shutdown the ORB here? + if (poa->shutting_down ()) + return 1; +#endif /* 0 */ + break; + /* NOTREACHED */ + } - if (result == -1) - return; - } /* NOTREACHED */ - return; + return 0; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) @@ -540,4 +560,4 @@ template class ACE_Strategy_Acceptor<TAO_OA_Connection_Handler, ACE_SOCK_ACCEPTO #pragma instantiate ACE_Dynamic_Service<TAO_Server_Strategy_Factory> #pragma instantiate ACE_Dynamic_Service<TAO_Client_Strategy_Factory> #pragma instantiate ACE_Strategy_Acceptor<TAO_OA_Connection_Handler, ACE_SOCK_ACCEPTOR> -#endif +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/orbobj.h b/TAO/tao/orbobj.h index 842c7b5af0e..5556341ad22 100644 --- a/TAO/tao/orbobj.h +++ b/TAO/tao/orbobj.h @@ -64,22 +64,29 @@ public: // Returns an indication of whether the ORB needs the <{main thread}> to // perform some work. - void perform_work (void); + int perform_work (ACE_Time_Value * = 0); // If called by the <{main thread}>, this operation performs an // implementation-defined unit of work. Otherwise, it does nothing. // - // It is platform specific how the application and ORB arrange to + // It is platform-specific how the application and ORB arrange to // use compatible threading primitives. - void run (void); - // Instructs the ORB to run its event loop in the current thread, - // not returning until the ORB has shut down. <{Note that this - // differs from the POA specification, which is reproduced below:}> + int run (ACE_Time_Value *tv = 0); + // Instructs the ORB to initialize itself and run its event loop in + // the current thread, not returning until the ORB has shut down. + // If an error occurs during initialization or a run-time this + // method will return -1. If <tv> is non-NULL then if no requests + // arrive at this thread before the timeout elapses we return to the + // caller with a value of 0 (this allows timeouts). Otherwise, if + // we've returned since we've been asked to shut down the value of 1 + // is returned. // - // Returns when the ORB has shut down. Different from the If called - // by the main thread, it enables the ORB to perform work using the - // main thread. Otherwise, it simply waits until the ORB has shut - // down. + // <{Note that this interface differs from the POA specification, + // which is reproduced below:}> + // + // Returns when the ORB has shut down. If called by the main + // thread, it enables the ORB to perform work using the main + // thread. Otherwise, it simply waits until the ORB has shut down. // // This operation can be used instead of perform_work() to give the // main thread to the ORB if there are no other activities that need @@ -89,13 +96,12 @@ public: void shutdown (CORBA::Boolean wait_for_completion); // This operation instructs the ORB to shut down. Shutting down the - // ORB causes all object adapters to be shut down. If the + // ORB causes all Object Adapters to be shut down. If the // wait_for_completion parameter is TRUE, this operation blocks // until all ORB processing (including request processing and object // deactivation or other operations associated with object adapters) // has completed. - // = <IUnknown> Support // // Stuff required for COM IUnknown support ... this class is @@ -112,9 +118,11 @@ public: TAO_Client_Strategy_Factory *client_factory (void); TAO_Server_Strategy_Factory *server_factory (void); TAO_ORB_Parameters *params (void); - void set_up_for_listening (void); + + int open (void); // Set up the internal acceptor to listen on the - // previously-specified port for requests. + // previously-specified port for requests. Returns -1 on failure, + // else 0. protected: CORBA_ORB (void); @@ -123,7 +131,7 @@ protected: private: ACE_SYNCH_MUTEX lock_; u_int refcount_; - CORBA::Boolean set_up_for_listening_called_; + CORBA::Boolean open_called_; // @@ Quite possibly everything btw ORB_CORE_STUFF should go into // the TAO_ORB_Core class... @@ -145,9 +153,11 @@ private: // The address of the endpoint on which we're listening for // connections and requests. - TAO_ACCEPTOR client_acceptor_; - // The acceptor listening for requests. - // ORB_CORE_STUFF + TAO_ACCEPTOR peer_acceptor_; + // The acceptor passively listening for connection requests. + + TAO_CONNECTOR peer_connector_; + // The connector actively initiating connection requests. // = NON-PROVIDED METHODS CORBA_ORB (const CORBA_ORB &); diff --git a/ace/Dump.h b/ace/Dump.h index 5217e42bfb2..4e857a90c87 100644 --- a/ace/Dump.h +++ b/ace/Dump.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp index 73386398687..78cf8b1225c 100644 --- a/ace/High_Res_Timer.cpp +++ b/ace/High_Res_Timer.cpp @@ -56,7 +56,7 @@ u_long ACE_High_Res_Timer::global_scale_factor_ = ACE_High_Res_Timer::get_regist // A scale_factor of 1000 converts nanosecond ticks to microseconds. // That is, on these platforms, 1 tick == 1 nanosecond. /* static */ -u_long ACE_High_Res_Timer::global_scale_factor_ = 1000; +u_long ACE_High_Res_Timer::global_scale_factor_ = ACE_ONE_SECOND_IN_MSECS; #endif /* ACE_WIN32 */ @@ -83,8 +83,8 @@ ACE_High_Res_Timer::reset (void) void ACE_High_Res_Timer::elapsed_time (ACE_Time_Value &tv) { - tv.sec ((long) ((this->end_ - this->start_) / global_scale_factor_) / 1000000); - tv.usec ((long) ((this->end_ - this->start_) / global_scale_factor_) % 1000000); + tv.sec ((long) ((this->end_ - this->start_) / global_scale_factor_) / ACE_ONE_SECOND_IN_USECS); + tv.usec ((long) ((this->end_ - this->start_) / global_scale_factor_) % ACE_ONE_SECOND_IN_USECS); } #if defined (ACE_HAS_POSIX_TIME) @@ -95,11 +95,11 @@ ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) // this implementation is based on that. // Just grab the nanoseconds. That is, leave off all values above - // microsecond. This equation is right! Don't mess with me! - // (It first strips off everything but the portion less than 1 usec. + // microsecond. This equation is right! Don't mess with me! (It + // first strips off everything but the portion less than 1 usec. // Then it converts that to nanoseconds by dividing by the scale - // factor to convert to usec, and multiplying by 1000.) - // The cast avoids a MSVC 4.1 compiler warning about narrowing. + // factor to convert to usec, and multiplying by 1000.) The cast + // avoids a MSVC 4.1 compiler warning about narrowing. #if defined (ACE_WIN32) || defined (ACE_HAS_LONGLONG_T) u_long nseconds = (u_long) ((this->end_ - this->start_) % global_scale_factor_ * 1000 / global_scale_factor_); #else @@ -115,11 +115,13 @@ ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) useconds = (this->end_ - this->start_) / global_scale_factor_; #if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS) - elapsed_time.tv_sec = (time_t) (useconds / 1000000); - elapsed_time.tv_nsec = (time_t) (useconds % 1000000 * 1000 + nseconds); + elapsed_time.tv_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS); + // Transforms one second in microseconds into nanoseconds. + elapsed_time.tv_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000 + nseconds); #else - elapsed_time.ts_sec = (time_t) (useconds / 1000000); - elapsed_time.ts_nsec = (time_t) (useconds % 1000000 * 1000 + nseconds); + elapsed_time.ts_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS); + // Transforms one second in microseconds into nanoseconds. + elapsed_time.ts_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000 + nseconds); #endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */ } #endif /* ACE_HAS_POSIX_TIME */ @@ -128,9 +130,9 @@ void ACE_High_Res_Timer::elapsed_time_incr (ACE_Time_Value &tv) { // Leave off any microseconds using DIV. - tv.sec ((long) (this->total_ / global_scale_factor_) / 1000000); + tv.sec ((long) (this->total_ / global_scale_factor_) / ACE_ONE_SECOND_IN_USECS); // Leave off any seconds using MOD. - tv.usec ((long) (this->total_ / global_scale_factor_) % 1000000); + tv.usec ((long) (this->total_ / global_scale_factor_) % ACE_ONE_SECOND_IN_USECS); } // The whole point is to get nanoseconds. However, our scale_factor @@ -176,12 +178,12 @@ ACE_High_Res_Timer::print_ave (const char *str, const int count, ACE_HANDLE hand this->elapsed_time (total_nanoseconds); // Separate to seconds and nanoseconds. - u_long total_secs = (u_long) (total_nanoseconds / 1000000000); + u_long total_secs = (u_long) (total_nanoseconds / ACE_ONE_SECOND_IN_NSECS); #if defined (ACE_WIN32) || defined (ACE_HAS_LONGLONG_T) - u_long extra_nsecs = (u_long) (total_nanoseconds % 1000000000); + u_long extra_nsecs = (u_long) (total_nanoseconds % ACE_ONE_SECOND_IN_NSECS); #else // Ignore the hi portion of the ACE_hrtime_t. - u_long extra_nsecs = total_nanoseconds.lo () % 1000000000; + u_long extra_nsecs = total_nanoseconds.lo () % ACE_ONE_SECOND_IN_NSECS; #endif /* ACE_WIN32 || ACE_HAS_LONGLONG_T */ char buf[100]; @@ -210,12 +212,12 @@ ACE_High_Res_Timer::print_total (const char *str, const int count, ACE_HANDLE ha this->elapsed_time (total_nanoseconds); // Separate to seconds and nanoseconds. - u_long total_secs = (u_long) (total_nanoseconds / 1000000000); + u_long total_secs = (u_long) (total_nanoseconds / ACE_ONE_SECOND_IN_NSECS); #if defined (ACE_WIN32) || defined (ACE_HAS_LONGLONG_T) - u_long extra_nsecs = (u_long) (total_nanoseconds % 1000000000); + u_long extra_nsecs = (u_long) (total_nanoseconds % ACE_ONE_SECOND_IN_NSECS); #else // Ignore the hi portion of the ACE_hrtime_t. - u_long extra_nsecs = total_nanoseconds.lo () % 1000000000; + u_long extra_nsecs = total_nanoseconds.lo () % ACE_ONE_SECOND_IN_NSECS; #endif /* ACE_WIN32 || ACE_HAS_LONGLONG_T */ char buf[100]; diff --git a/ace/High_Res_Timer.i b/ace/High_Res_Timer.i index 6bd78736df5..8d360217f41 100644 --- a/ace/High_Res_Timer.i +++ b/ace/High_Res_Timer.i @@ -10,8 +10,8 @@ ACE_High_Res_Timer::hrtime_to_tv (ACE_Time_Value &tv, // The following are based on the units of global_scale_factor_ // being 1/microsecond. Therefore, dividing by it converts // clock ticks to microseconds. - tv.sec ((long) (hrt / global_scale_factor_) / 1000000); - tv.usec ((long) (hrt / global_scale_factor_) % 1000000); + tv.sec ((long) (hrt / global_scale_factor_) / ACE_ONE_SECOND_IN_USECS); + tv.usec ((long) (hrt / global_scale_factor_) % ACE_ONE_SECOND_IN_USECS); } @@ -45,7 +45,7 @@ ACE_High_Res_Timer::gettime (void) ACE_Time_Value tv = ACE_OS::gettimeofday (); // Return the time in microseconds because the global_scale_factor_ // is 1. - return tv.sec () * 1000000 + tv.usec (); + return tv.sec () * ACE_ONE_SECOND_IN_USECS + tv.usec (); } #endif /* ACE_WIN32 */ diff --git a/ace/OS.cpp b/ace/OS.cpp index 5a0c9ccc839..6c979f80565 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -98,34 +98,34 @@ ACE_Time_Value::normalize (void) // ACE_TRACE ("ACE_Time_Value::normalize"); // New code from Hans Rohnert... - if (this->tv_.tv_usec >= ONE_SECOND) + if (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS) { do { this->tv_.tv_sec++; - this->tv_.tv_usec -= ONE_SECOND; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; } - while (this->tv_.tv_usec >= ONE_SECOND); + while (this->tv_.tv_usec >= ACE_ONE_SECOND_IN_USECS); } - else if (this->tv_.tv_usec <= -ONE_SECOND) + else if (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS) { do { this->tv_.tv_sec--; - this->tv_.tv_usec += ONE_SECOND; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; } - while (this->tv_.tv_usec <= -ONE_SECOND); + while (this->tv_.tv_usec <= -ACE_ONE_SECOND_IN_USECS); } if (this->tv_.tv_sec >= 1 && this->tv_.tv_usec < 0) { this->tv_.tv_sec--; - this->tv_.tv_usec += ONE_SECOND; + this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS; } else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0) { this->tv_.tv_sec++; - this->tv_.tv_usec -= ONE_SECOND; + this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS; } } @@ -22,6 +22,10 @@ // configuration file (e.g., config-sunos5-sunc++-4.x.h). #include "ace/config.h" +#define ACE_ONE_SECOND_IN_MSECS 1000L +#define ACE_ONE_SECOND_IN_USECS 1000000L +#define ACE_ONE_SECOND_IN_NSECS 1000000000L + #if defined (ACE_NO_INLINE) // ACE inlining has been explicitly disabled. Implement // internally within ACE by undefining __ACE_INLINE__. @@ -107,10 +107,6 @@ typedef const struct timespec * ACE_TIMESPEC_PTR; #include /**/ <malloc.h> #endif /* ACE_LACKS_MALLOC_H */ -// Don't put this in the class since it will expand the size! Also, -// can't make this an enum due to compiler bugs on some platforms... -static const long ONE_SECOND = 1000000L; - // Returns the value of the object as a timeval. ACE_INLINE @@ -143,7 +139,7 @@ ACE_Time_Value::set (double d) // ACE_TRACE ("ACE_Time_Value::set"); long l = (long) d; this->tv_.tv_sec = l; - this->tv_.tv_usec = (long) ((d - (double) l) * 1000000); + this->tv_.tv_usec = (long) ((d - (double) l) * ACE_ONE_SECOND_IN_USECS); this->normalize (); } @@ -158,9 +154,11 @@ ACE_Time_Value::set (const timespec_t &tv) // ACE_TRACE ("ACE_Time_Value::set"); #if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS) this->tv_.tv_sec = tv.tv_sec; + // Convert nanoseconds into microseconds. this->tv_.tv_usec = tv.tv_nsec / 1000; #else this->tv_.tv_sec = tv.ts_sec; + // Convert nanoseconds into microseconds. this->tv_.tv_usec = tv.ts_nsec / 1000; #endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */ @@ -242,9 +240,11 @@ ACE_Time_Value::operator timespec_t () const timespec_t tv; #if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS) tv.tv_sec = this->tv_.tv_sec; + // Convert nanoseconds into microseconds. tv.tv_nsec = this->tv_.tv_usec * 1000; #else tv.ts_sec = this->tv_.tv_sec; + // Convert nanoseconds into microseconds. tv.ts_nsec = this->tv_.tv_usec * 1000; #endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */ return tv; @@ -2241,7 +2241,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) #elif defined (VXWORKS) int ticks_per_sec = ::sysClkRateGet (); int ticks = tv.sec() * ticks_per_sec + - tv.usec () * ticks_per_sec / 1000000; + tv.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::semTake (s->sema_, ticks), ace_result_), int, -1); #endif /* ACE_HAS_STHREADS */ #else @@ -5518,7 +5518,7 @@ ACE_OS::ualarm (u_int usecs, u_int interval) return ::ualarm (usecs, interval); #elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (interval); - return ::alarm (usecs * 1000000); + return ::alarm (usecs * ACE_ONE_SECOND_IN_USECS); #else ACE_UNUSED_ARG (usecs); ACE_UNUSED_ARG (interval); @@ -5533,8 +5533,8 @@ ACE_OS::ualarm (const ACE_Time_Value &tv, // ACE_TRACE ("ACE_OS::ualarm"); #if defined (ACE_HAS_UALARM) - u_int usecs = (tv.sec () * 1000000) + tv.usec (); - u_int interval = (tv_interval.sec () * 1000000) + tv_interval.usec (); + u_int usecs = (tv.sec () * ACE_ONE_SECOND_IN_USECS) + tv.usec (); + u_int interval = (tv_interval.sec () * ACE_ONE_SECOND_IN_USECS) + tv_interval.usec (); return ::ualarm (usecs, interval); #elif !defined (ACE_LACKS_UNIX_SIGNALS) ACE_UNUSED_ARG (tv_interval); @@ -6913,7 +6913,7 @@ ACE_OS::gethrtime (void) ::read_real_time(&tb, TIMEBASE_SZ); ::time_base_to_time(&tb, TIMEBASE_SZ); - return tb.tb_high * 1000000000L + tb.tb_low; + return tb.tb_high * ACE_ONE_SECOND_IN_NSECS + tb.tb_low; #elif defined (linux) # if defined (ACE_HAS_PENTIUM) ACE_hrtime_t now; @@ -6938,7 +6938,7 @@ ACE_OS::gethrtime (void) return now; # else const ACE_Time_Value now = ACE_OS::gettimeofday (); - return now.msec () * 1000000L /* nanoseconds/millsecond */; + return now.msec () * 1000000L /* Turn millseconds into nanoseconds */; # endif /* ACE_HAS_PENTIUM || __alpha */ #elif defined (ACE_WIN32) && defined (ACE_HAS_PENTIUM) // Issue the RDTSC assembler instruction to get the number of clock @@ -6977,10 +6977,10 @@ ACE_OS::gethrtime (void) ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); - return ts.tv_sec * 1000000000 + ts.tv_nsec; + return ts.tv_sec * ACE_ONE_SECOND_IN_NSECS + ts.tv_nsec; #else const ACE_Time_Value now = ACE_OS::gettimeofday (); - return now.msec () * 1000000L /* nanoseconds/millsecond */; + return now.msec () * 1000000L /* Turn millseconds into nanoseconds */; #endif /* ACE_HAS_HI_RES_TIMER */ } @@ -7194,7 +7194,7 @@ ACE_OS::sleep (u_int seconds) { // ACE_TRACE ("ACE_OS::sleep"); #if defined (ACE_WIN32) - ::Sleep (seconds * 1000); + ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS); return 0; #elif defined (ACE_HAS_CLOCK_GETTIME) struct timespec rqtp; diff --git a/ace/Profile_Timer.cpp b/ace/Profile_Timer.cpp index dd7a82214bd..bd1885ee365 100644 --- a/ace/Profile_Timer.cpp +++ b/ace/Profile_Timer.cpp @@ -98,11 +98,14 @@ ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et) ACE_Profile_Timer::Rusage &begin = this->begin_usage_; this->subtract (td, end.pr_tstamp, begin.pr_tstamp); - et.real_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000); + // Convert nanoseconds into seconds. + et.real_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS; this->subtract (td, end.pr_utime, begin.pr_utime); - et.user_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000); + // Convert nanoseconds into seconds. + et.user_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS; this->subtract (td, end.pr_stime, begin.pr_stime); - et.system_time = td.tv_sec + ((double) td.tv_nsec) / (1000 * 1000 * 1000); + // Convert nanoseconds into seconds. + et.system_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS; } // Determine the difference between T1 and T2. @@ -119,7 +122,7 @@ ACE_Profile_Timer::subtract (timespec_t &tdiff, timespec_t &t1, timespec_t &t0) while (tdiff.tv_nsec < 0) { tdiff.tv_sec--; - tdiff.tv_nsec += (1000 * 1000 * 1000); + tdiff.tv_nsec += ACE_ONE_SECOND_IN_NSECS; } } @@ -172,27 +175,27 @@ ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et) #if defined (ACE_WIN32) ACE_Time_Value atv = this->end_time_ - this->begin_time_; - et.real_time = atv.sec () + ((double) atv.usec ()) / (1000 * 1000); + et.real_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS; atv = ACE_Time_Value (this->end_usage_.ru_utime) - ACE_Time_Value (this->begin_usage_.ru_utime); - et.user_time = atv.sec () + ((double) atv.usec ()) / (1000 * 1000); + et.user_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS; atv = ACE_Time_Value (this->end_usage_.ru_stime) - ACE_Time_Value (this->begin_usage_.ru_stime); - et.system_time = atv.sec () + ((double) atv.usec ()) / (1000 * 1000); + et.system_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS; #else timeval td; this->subtract (td, this->end_time_, this->begin_time_); - et.real_time = td.tv_sec + ((double) td.tv_usec) / (1000 * 1000); + et.real_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS; this->subtract (td, this->end_usage_.ru_utime, this->begin_usage_.ru_utime); - et.user_time = td.tv_sec + ((double) td.tv_usec) / (1000 * 1000); + et.user_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS; this->subtract (td, this->end_usage_.ru_stime, this->begin_usage_.ru_stime); - et.system_time = td.tv_sec + ((double) td.tv_usec) / (1000 * 1000); + et.system_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS; #endif /* ACE_WIN32 */ } @@ -210,7 +213,7 @@ ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0) while (tdiff.tv_usec < 0) { tdiff.tv_sec--; - tdiff.tv_usec += (1000 * 1000); + tdiff.tv_usec += ACE_ONE_SECOND_IN_USECS; } } @@ -243,10 +246,10 @@ ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et) timer_.elapsed_time (delta_t); #if defined (ACE_WIN32) || defined (ACE_HAS_LONGLONG_T) - et.real_time = delta_t / 1000000000.0; + et.real_time = delta_t / (double) ACE_ONE_SECOND_IN_USECS; #else - et.real_time = (double) ULONG_MAX / 1000000000.0 * (double) delta_t.hi () + - (double) delta_t.lo () / 1000000000.0; + et.real_time = (double) ULONG_MAX / (double) ACE_ONE_SECOND_IN_USECS * (double) delta_t.hi () + + (double) delta_t.lo () / (double) ACE_ONE_SECOND_IN_USECS; #endif /* ACE_WIN32 || ACE_HAS_LONGLONG_T */ et.user_time = 0; et.system_time = 0; diff --git a/ace/Timer_List.cpp b/ace/Timer_List.cpp index 99c7e084ba8..8bae22eb456 100644 --- a/ace/Timer_List.cpp +++ b/ace/Timer_List.cpp @@ -11,11 +11,9 @@ #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Async_Timer_Queue_Adapter<ACE_Timer_List_T<ACE_Event_Handler*,ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,ACE_SYNCH_RECURSIVE_MUTEX> >; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Timer_List_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> #pragma instantiate ACE_Timer_List_Iterator_T<ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Async_Timer_Queue_Adapter<ACE_Timer_List_T<ACE_Event_Handler*,ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>,ACE_SYNCH_RECURSIVE_MUTEX> > #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/ace/config-tandem.h b/ace/config-tandem.h index 2631d5bb44d..487554672f4 100644 --- a/ace/config-tandem.h +++ b/ace/config-tandem.h @@ -253,7 +253,6 @@ //#define ACE_TIMER_SKEW 1000 * 10 //#endif /* ACE_TIMER_SKEW */ - // Platform supports the getrusage() system call. //#define ACE_HAS_GETRUSAGE //Platform uses non-const char * in calls to gethostbyaddr, gethostbyname, diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp index 886212f396e..8ba287f2af3 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.cpp @@ -81,8 +81,11 @@ Handle_Thr_Acceptor<SH, PR_AC_2>::init (int argc, char *argv[]) // Initialize the Acceptor base class, passing in the desired // concurrency strategy. - else if (this->open (local_addr, ACE_Reactor::instance (), - 0, 0, &this->thr_strategy_) == -1) + else if (this->open (local_addr, + ACE_Reactor::instance (), + 0, + 0, + &this->thr_strategy_) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); else return 0; @@ -208,6 +211,5 @@ template class Handle_Thr_Acceptor<CLI_STREAM, THR_ACCEPTOR>; #pragma instantiate Handle_Thr_Acceptor<CLI_STREAM, THR_ACCEPTOR> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - #endif /* ACE_HAS_THREADS */ #endif /* ACE_HANDLE_THR_STREAM_C */ diff --git a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h index df91e05d821..2b6f5133665 100644 --- a/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h +++ b/examples/Service_Configurator/IPC-tests/server/Handle_Thr_Stream.h @@ -1,8 +1,6 @@ /* -*- C++ -*- */ // $Id$ -// Handle connections from remote INET connections. - #if !defined (_HANDLE_THR_STREAM_H) #define _HANDLE_THR_STREAM_H @@ -13,6 +11,9 @@ template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> class Handle_Thr_Acceptor : public ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> + // = TITLE + // This factory creates new <SVC_HANDLERS> and runs them with the + // configured <ACE_Thread_Strategy>. { public: // = Initialization and termination. @@ -35,10 +36,11 @@ private: // Threading flags. }; -// This class interacts with the client, running in a separate -// thread... template <ACE_PEER_STREAM_1> class CLI_Stream : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_MT_SYNCH> + // = TITLE + // This class interacts with the client, running in a separate + // thread and handles connections from remote TCP/IP connections. { public: CLI_Stream (ACE_Thread_Manager * = 0); diff --git a/tests/Priority_Reactor_Test.cpp b/tests/Priority_Reactor_Test.cpp index 98b12b44aa9..7680b07252f 100644 --- a/tests/Priority_Reactor_Test.cpp +++ b/tests/Priority_Reactor_Test.cpp @@ -9,12 +9,15 @@ // Priority_Reactor_Test.cpp // // = DESCRIPTION -// This is a test of the <ACE_Priority_Reactor>. -// The test forks two processes (for a total of three processes) -// which connect to the main process and -// The clients send data to a connector, interestingly enough the -// acceptor will give more priority to the second connection, -// which should run always before the first one. +// This is a test of the <ACE_Priority_Reactor>. The test forks +// two processes (for a total of three processes) which connect to +// the main process and The clients send data to a connector, +// interestingly enough the acceptor will give more priority to +// the second connection, which should run always before the first +// one. +// +// The test itself is interesting, it shows how to write very +// simple <ACE_Svc_Handler>, <ACE_Connectors> and <ACE_Acceptors>. // // = AUTHOR // Carlos O'Ryan |