diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-31 21:48:20 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-07-31 21:48:20 +0000 |
commit | 86c5f836d1a679208716a422839d7da38ba41059 (patch) | |
tree | 1b3da514a0eb2064d0b27c62011db9492387b7dc /examples/ASX | |
parent | 13c10349a654c59c85bb62c7f7b9ab8e1424814c (diff) | |
download | ATCD-86c5f836d1a679208716a422839d7da38ba41059.tar.gz |
added ACE_HAS_INSTANTIATION_PRAGMA support
Diffstat (limited to 'examples/ASX')
4 files changed, 103 insertions, 65 deletions
diff --git a/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp index 6d144a05216..a54225fa916 100644 --- a/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp +++ b/examples/ASX/Event_Server/Event_Server/Peer_Router.cpp @@ -17,7 +17,7 @@ Peer_Router_Context::send_peers (ACE_Message_Block *mb) // Skip past the header and get the message to send. ACE_Message_Block *data_block = mb->cont (); - + // "Multicast" the data to *all* the registered peers. for (PEER_ENTRY *ss = 0; @@ -25,13 +25,13 @@ Peer_Router_Context::send_peers (ACE_Message_Block *mb) map_iter.advance ()) { if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_DEBUG, - "(%t) sending to peer via handle %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) sending to peer via handle %d\n", ss->ext_id_)); iterations++; // Increment reference count before sending since the // Peer_Handler might be running in its own thread of control. - bytes += ss->int_id_->put (data_block->duplicate ()); + bytes += ss->int_id_->put (data_block->duplicate ()); } mb->release (); @@ -61,7 +61,7 @@ Peer_Router_Context::release (void) } int -Peer_Router_Context::bind_peer (ROUTING_KEY key, +Peer_Router_Context::bind_peer (ROUTING_KEY key, Peer_Handler *peer_handler) { return this->peer_map_.bind (key, peer_handler); @@ -81,17 +81,17 @@ Peer_Router_Context::Peer_Router_Context (u_short port) else { ACE_INET_Addr addr; - + if (this->acceptor().get_local_addr (addr) != -1) - ACE_DEBUG ((LM_DEBUG, - "(%t) initializing %s on port = %d, handle = %d, this = %u\n", - addr.get_port_number () == Options::instance ()->supplier_port () ? + ACE_DEBUG ((LM_DEBUG, + "(%t) initializing %s on port = %d, handle = %d, this = %u\n", + addr.get_port_number () == Options::instance ()->supplier_port () ? "Supplier_Handler" : "Consumer_Handler", addr.get_port_number (), - this->acceptor().get_handle (), + this->acceptor().get_handle (), this)); else - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "%p\n", "get_local_addr")); } } @@ -99,7 +99,7 @@ Peer_Router_Context::Peer_Router_Context (u_short port) Peer_Router_Context::~Peer_Router_Context (void) { // Free up the handle and close down the listening socket. - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) closing down Peer_Router_Context\n")); // Close down the Acceptor and take ourselves out of the Reactor. @@ -114,8 +114,8 @@ Peer_Router_Context::~Peer_Router_Context (void) map_iter.advance ()) { if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_DEBUG, - "(%t) closing down peer on handle %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) closing down peer on handle %d\n", ss->ext_id_)); if (ACE_Reactor::instance ()->remove_handler @@ -141,7 +141,7 @@ Peer_Router_Context::peer_router (Peer_Router *pr) int Peer_Router_Context::make_svc_handler (Peer_Handler *&sh) -{ +{ ACE_NEW_RETURN (sh, Peer_Handler (this), -1); return 0; } @@ -175,9 +175,9 @@ Peer_Handler::svc (void) { db = new Message_Block (BUFSIZ); hb = new Message_Block (sizeof (ROUTING_KEY), Message_Block::MB_PROTO, db); - + if ((n = this->peer_.recv (db->rd_ptr (), db->size ())) == -1) - LM_ERROR_RETURN ((LOG_ERROR, "%p", "recv failed"), -1); + LM_ERROR_RETURN ((LOG_ERROR, "%p", "recv failed"), -1); else if (n == 0) // Client has closed down the connection. { if (this->prc_->peer_router ()->unbind_peer (this->get_handle ()) == -1) @@ -186,7 +186,7 @@ Peer_Handler::svc (void) return -1; // We do not need to be deregistered by reactor // as we were not registered at all } - else + else // Transform incoming buffer into a Message and pass // downstream. { @@ -216,7 +216,7 @@ Peer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *tv) int result = 0; - result = this->peer ().send_n (mb->rd_ptr (), + result = this->peer ().send_n (mb->rd_ptr (), mb->length ()); // Release the memory. mb->release (); @@ -241,11 +241,11 @@ Peer_Handler::open (void *) // here. if (this->activate (Options::instance ()->t_flags ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "activation of thread failed"), -1); - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ((LM_DEBUG, "(%t) Peer_Handler::open registering with Reactor for handle_input\n")); #else // Register with the Reactor to receive messages from our Peer. - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); #endif @@ -284,7 +284,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) ssize_t n = this->peer ().recv (db->rd_ptr (), db->size ()); if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p", "recv failed"), -1); else if (n == 0) // Client has closed down the connection. { if (this->prc_->unbind_peer (this->get_handle ()) == -1) @@ -293,7 +293,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) ACE_DEBUG ((LM_DEBUG, "(%t) shutting down handle %d\n", h)); return -1; // Instruct the ACE_Reactor to deregister us by returning -1. } - else + else { // Transform incoming buffer into a Message. @@ -302,7 +302,7 @@ Peer_Handler::handle_input (ACE_HANDLE h) db->wr_ptr (n); // Second, copy the "address" into the header block. - *(ACE_HANDLE *) hb->rd_ptr () = this->get_handle (); + *(ACE_HANDLE *) hb->rd_ptr () = this->get_handle (); // Third, update the write pointer in the header block. hb->wr_ptr (sizeof (ACE_HANDLE)); @@ -353,10 +353,17 @@ Peer_Router::control (ACE_Message_Block *mb) #endif /* _PEER_ROUTER_C */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Map_Entry<ROUTING_KEY, Peer_Handler *>; template class ACE_Map_Iterator<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Peer_Handler, ACE_SOCK_ACCEPTOR> +#pragma instantiate ACE_Map_Entry<ROUTING_KEY, Peer_Handler *> +#pragma instantiate ACE_Map_Iterator<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ROUTING_KEY, Peer_Handler *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/ASX/Event_Server/Transceiver/transceiver.cpp b/examples/ASX/Event_Server/Transceiver/transceiver.cpp index c8904bcbb04..0df775fa37d 100644 --- a/examples/ASX/Event_Server/Transceiver/transceiver.cpp +++ b/examples/ASX/Event_Server/Transceiver/transceiver.cpp @@ -20,7 +20,7 @@ static char role = 'S'; // Handle the command-line arguments. -static void +static void parse_args (int argc, char *argv[]) { ACE_Get_Opt get_opt (argc, argv, "Ch:p:S"); @@ -44,7 +44,7 @@ parse_args (int argc, char *argv[]) role = c; break; default: - ACE_ERROR ((LM_ERROR, + ACE_ERROR ((LM_ERROR, "usage: %n [-p portnum] [-h host_name]\n%a", 1)); /* NOTREACHED */ break; @@ -61,7 +61,7 @@ parse_args (int argc, char *argv[]) class Event_Transceiver : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> // = TITLE // Generate and receives messages from the event server. - // + // // = DESCRIPTION // This class is both a consumer and supplier of events, i.e., // it is a ``transceiver.'' @@ -92,23 +92,23 @@ private: // Writes data from ACE_STDIN to socket. }; -int +int Event_Transceiver::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { - ACE_Reactor::end_event_loop(); + ACE_Reactor::end_event_loop(); return 0; } // Close down via SIGINT or SIGQUIT. -int -Event_Transceiver::handle_signal (int signum, - siginfo_t *, +int +Event_Transceiver::handle_signal (int signum, + siginfo_t *, ucontext_t *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); - + ACE_Reactor::end_event_loop(); return 0; } @@ -116,19 +116,19 @@ Event_Transceiver::handle_signal (int signum, Event_Transceiver::Event_Transceiver (void) { ACE_Sig_Set sig_set; - + sig_set.sig_add (SIGINT); sig_set.sig_add (SIGQUIT); #if !defined (ACE_WIN32) - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (sig_set, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); #else - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (SIGINT, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); @@ -140,8 +140,8 @@ Event_Transceiver::Event_Transceiver (void) else if (ACE::register_stdin_handler (this, ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) - ACE_ERROR ((LM_ERROR, - "%p\n", + ACE_ERROR ((LM_ERROR, + "%p\n", "register_stdin_handler")); } @@ -152,9 +152,9 @@ Event_Transceiver::open (void *) // socket. if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "register_handler"), + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "register_handler"), -1); return 0; } @@ -206,9 +206,9 @@ Event_Transceiver::receiver (void) return result; } -int -main (int argc, char *argv[]) -{ +int +main (int argc, char *argv[]) +{ ACE_Service_Config daemon (argv[0]); parse_args (argc, argv); @@ -228,11 +228,19 @@ main (int argc, char *argv[]) return 0; } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR>; template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Event_Transceiver>; template class ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR> +#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Event_Transceiver> +#pragma instantiate ACE_Map_Entry<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Event_Transceiver> *, ACE_SYNCH_RW_MUTEX> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp index ca472f23db4..d797d6668b5 100644 --- a/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp +++ b/examples/ASX/UPIPE_Event_Server/Consumer_Router.cpp @@ -11,7 +11,7 @@ int Consumer_Handler::open (void *a) { CONSUMER_FACTORY *af = (CONSUMER_FACTORY *) a; - this->router_task_ = af->router (); + this->router_task_ = af->router (); return this->Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>::open (a); } @@ -62,7 +62,7 @@ Consumer_Router::close (u_long) // Handle incoming messages in a separate thread.. -int +int Consumer_Router::svc (void) { ACE_Thread_Control tc (this->thr_mgr ()); @@ -85,7 +85,7 @@ Consumer_Router::svc (void) // Send a MESSAGE_BLOCK to the supplier(s).. -int +int Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) { ACE_ASSERT (this->is_reader ()); @@ -104,21 +104,21 @@ Consumer_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) // Return information about the Client_Router ACE_Module.. -int +int Consumer_Router::info (char **strp, size_t length) const { char buf[BUFSIZ]; ACE_UPIPE_Addr addr; const char *mod_name = this->name (); ACE_UPIPE_Acceptor &sa = (ACE_UPIPE_Acceptor &) *this->acceptor_; - + if (sa.get_local_addr (addr) == -1) return -1; - + ACE_OS::sprintf (buf, "%s\t /%s %s", mod_name, "upipe", "# consumer router\n"); - + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) return -1; else @@ -126,7 +126,7 @@ Consumer_Router::info (char **strp, size_t length) const return ACE_OS::strlen (mod_name); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Acceptor<Consumer_Handler, ACE_UPIPE_ACCEPTOR>; template class Acceptor_Factory<Consumer_Handler, CONSUMER_KEY>; template class Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY>; @@ -134,5 +134,14 @@ template class Peer_Router<Consumer_Handler, CONSUMER_KEY>; template class ACE_Map_Entry<CONSUMER_KEY, Consumer_Handler *>; template class ACE_Map_Iterator<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex>; template class ACE_Map_Manager<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Acceptor<Consumer_Handler, ACE_UPIPE_ACCEPTOR> +#pragma instantiate Acceptor_Factory<Consumer_Handler, CONSUMER_KEY> +#pragma instantiate Peer_Handler<CONSUMER_ROUTER, CONSUMER_KEY> +#pragma instantiate Peer_Router<Consumer_Handler, CONSUMER_KEY> +#pragma instantiate ACE_Map_Entry<CONSUMER_KEY, Consumer_Handler *> +#pragma instantiate ACE_Map_Iterator<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Map_Manager<CONSUMER_KEY, Consumer_Handler *, ACE_RW_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ diff --git a/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp index 9f2de1c41e6..e0956ed6215 100644 --- a/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp +++ b/examples/ASX/UPIPE_Event_Server/Supplier_Router.cpp @@ -11,7 +11,7 @@ int Supplier_Handler::open (void *a) { SUPPLIER_FACTORY *af = (SUPPLIER_FACTORY *) a; - this->router_task_ = af->router (); + this->router_task_ = af->router (); return this->Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY>::open (a); } @@ -29,7 +29,7 @@ Supplier_Router::Supplier_Router (ACE_Thread_Manager *tm) // Handle incoming messages in a separate thread.. -int +int Supplier_Router::svc (void) { ACE_ASSERT (this->is_writer ()); @@ -85,7 +85,7 @@ Supplier_Router::close (u_long) // Send a MESSAGE_BLOCK to the supplier(s).. -int +int Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) { ACE_ASSERT (this->is_writer ()); @@ -104,7 +104,7 @@ Supplier_Router::put (ACE_Message_Block *mb, ACE_Time_Value *) // Return information about the Supplier_Router ACE_Module.. -int +int Supplier_Router::info (char **strp, size_t length) const { char buf[BUFSIZ]; @@ -114,11 +114,11 @@ Supplier_Router::info (char **strp, size_t length) const if (sa.get_local_addr (addr) == -1) return -1; - + ACE_OS::sprintf (buf, "%s\t %s/ %s", mod_name, "upipe", "# supplier router\n"); - + if (*strp == 0 && (*strp = ACE_OS::strdup (mod_name)) == 0) return -1; else @@ -126,7 +126,7 @@ Supplier_Router::info (char **strp, size_t length) const return ACE_OS::strlen (mod_name); } -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY>; template class ACE_Acceptor<Supplier_Handler, ACE_UPIPE_ACCEPTOR>; template class ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_MT_SYNCH>; @@ -139,6 +139,20 @@ template class ACE_Read_Guard<ACE_RW_Mutex>; template class ACE_Write_Guard<ACE_RW_Mutex>; template class ACE_Guard<ACE_RW_Mutex>; template class ACE_TSS<ACE_Dynamic>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate Acceptor_Factory<Supplier_Handler, SUPPLIER_KEY> +#pragma instantiate ACE_Acceptor<Supplier_Handler, ACE_UPIPE_ACCEPTOR> +#pragma instantiate ACE_Svc_Handler<ACE_UPIPE_STREAM, ACE_MT_SYNCH> +#pragma instantiate Peer_Handler<SUPPLIER_ROUTER, SUPPLIER_KEY> +#pragma instantiate Peer_Router<Supplier_Handler, SUPPLIER_KEY> +#pragma instantiate ACE_Map_Entry<SUPPLIER_KEY, Supplier_Handler *> +#pragma instantiate ACE_Map_Iterator<SUPPLIER_KEY, Supplier_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Map_Manager<SUPPLIER_KEY, Supplier_Handler *, ACE_RW_Mutex> +#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_TSS<ACE_Dynamic> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ |