diff options
Diffstat (limited to 'examples/Connection/blocking')
-rw-r--r-- | examples/Connection/blocking/SPIPE-acceptor.cpp | 30 | ||||
-rw-r--r-- | examples/Connection/blocking/SPIPE-connector.cpp | 41 |
2 files changed, 41 insertions, 30 deletions
diff --git a/examples/Connection/blocking/SPIPE-acceptor.cpp b/examples/Connection/blocking/SPIPE-acceptor.cpp index a1548f39205..c103dbb82a0 100644 --- a/examples/Connection/blocking/SPIPE-acceptor.cpp +++ b/examples/Connection/blocking/SPIPE-acceptor.cpp @@ -20,17 +20,17 @@ Svc_Handler::~Svc_Handler (void) { } -int +int Svc_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "client connected on handle %d\n", this->peer ().get_handle ())); if (this->ar_.open (*this, this->peer ().get_handle ()) == -1) - return -1; + return -1; return this->ar_.read (this->mb_, this->mb_.size ()); } -void +void Svc_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { if (result.success () && result.bytes_transferred () > 0) @@ -39,7 +39,7 @@ Svc_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) // Print out the message received from the server. ACE_DEBUG ((LM_DEBUG, "(%t) message size %d.\n", result.message_block ().length ())); ACE_DEBUG ((LM_DEBUG, "%s", result.message_block ().rd_ptr ())); - + this->ar_.read (this->mb_, this->mb_.size ()); } else @@ -57,7 +57,7 @@ IPC_Server::~IPC_Server (void) { } -int +int IPC_Server::init (int argc, char *argv[]) { if (this->parse_args (argc, argv) == -1) @@ -77,7 +77,7 @@ IPC_Server::init (int argc, char *argv[]) return 0; } -int +int IPC_Server::fini (void) { return 0; @@ -95,13 +95,13 @@ IPC_Server::parse_args (int argc, char *argv[]) switch (c) { case 'r': - ACE_OS::strncpy (rendezvous_, + ACE_OS::strncpy (rendezvous_, ACE_WIDE_STRING (get_opt.optarg), sizeof rendezvous_ / sizeof TCHAR); break; case 't': n_threads_ = ACE_OS::atoi (get_opt.optarg); - ACE_DEBUG ((LM_DEBUG, "%s == %d.\n", + ACE_DEBUG ((LM_DEBUG, "%s == %d.\n", get_opt.optarg, n_threads_)); ACE_Proactor::instance(2*n_threads_); @@ -130,14 +130,14 @@ run_reactor_event_loop (void *) return 0; } -int +int IPC_Server::svc (void) { // Performs the iterative server activities. while (ACE_Reactor::event_loop_done() == 0) { Svc_Handler sh; - + // Create a new SH endpoint, which performs all processing in // its open() method (note no automatic restart if errno == // EINTR). @@ -163,7 +163,7 @@ IPC_Server::svc (void) ACE_DEBUG ((LM_DEBUG, "(%t) main thread exiting.\n")); } } - + /* NOTREACHED */ return 0; } @@ -171,7 +171,11 @@ IPC_Server::svc (void) #endif /* SPIPE_ACCEPTOR_C */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Concurrency_Strategy<Svc_Handler>; template class ACE_Oneshot_Acceptor<Svc_Handler, ACE_SPIPE_ACCEPTOR>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Concurrency_Strategy<Svc_Handler> +#pragma instantiate ACE_Oneshot_Acceptor<Svc_Handler, ACE_SPIPE_ACCEPTOR> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + diff --git a/examples/Connection/blocking/SPIPE-connector.cpp b/examples/Connection/blocking/SPIPE-connector.cpp index 60ef04275ba..8c05d458a39 100644 --- a/examples/Connection/blocking/SPIPE-connector.cpp +++ b/examples/Connection/blocking/SPIPE-connector.cpp @@ -18,7 +18,7 @@ Peer_Handler::~Peer_Handler () { } -int +int Peer_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, "activating %d\n", this->get_handle ())); @@ -31,12 +31,12 @@ Peer_Handler::open (void *) ACE_Reactor::instance (), ACE_Thread_Manager::instance ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); - else + else return 0; } else // If iterations_ has been set, send iterations_ buffers. { - char *buffer = + char *buffer = "Oh give me a home\n" "Where the buffalo roam,\n" "And the deer and the antelope play.\n" @@ -44,18 +44,18 @@ Peer_Handler::open (void *) "A discouraging word,\n" "And the skies are not cloudy all day.\n"; int length = ACE_OS::strlen (buffer); - + while (iterations_-- > 0 && this->peer ().send_n (buffer, length) == length) continue; - + this->peer ().close (); ACE_Reactor::end_event_loop(); return 0; } } -int +int Peer_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; @@ -67,7 +67,7 @@ Peer_Handler::handle_input (ACE_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "write failed"), -1); else if (n == 0) /* Explicitly close the connection. */ { - if (this->peer ().close () == -1) + if (this->peer ().close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), 1); return -1; } @@ -76,7 +76,7 @@ Peer_Handler::handle_input (ACE_HANDLE) return 0; } -int +int Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { @@ -84,7 +84,7 @@ Peer_Handler::handle_close (ACE_HANDLE, return 0; } -ACE_HANDLE +ACE_HANDLE Peer_Handler::get_handle (void) const { return this->peer ().get_handle (); @@ -109,7 +109,7 @@ IPC_Client::~IPC_Client (void) // Dynamic linking hooks. -int +int IPC_Client::init (int argc, char *argv[]) { if (this->parse_args (argc, argv) == -1) @@ -122,7 +122,7 @@ IPC_Client::init (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "Opening %s\n", ACE_MULTIBYTE_STRING (rendezvous_))); Peer_Handler *ph; - + ACE_NEW_RETURN (ph, Peer_Handler (iterations_), -1); // Connect to the peer, reusing the local addr if necessary. @@ -138,20 +138,20 @@ IPC_Client::init (int argc, char *argv[]) return 0; } -int +int IPC_Client::fini (void) { return 0; } -int +int IPC_Client::svc (void) { ACE_Reactor::run_event_loop (); return 0; } -int +int IPC_Client::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { return 0; @@ -169,7 +169,7 @@ IPC_Client::parse_args (int argc, char *argv[]) switch (c) { case 'r': - ACE_OS::strncpy (rendezvous_, + ACE_OS::strncpy (rendezvous_, ACE_WIDE_STRING (get_opt.optarg), sizeof rendezvous_ / sizeof TCHAR); break; @@ -192,10 +192,17 @@ IPC_Client::parse_args (int argc, char *argv[]) #endif /* SPIPE_CONNECTOR */ -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Connector<Peer_Handler, ACE_SPIPE_CONNECTOR>; template class ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX>; template class ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH>; template class ACE_Svc_Tuple<Peer_Handler>; -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Connector<Peer_Handler, ACE_SPIPE_CONNECTOR> +#pragma instantiate ACE_Map_Iterator<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<Peer_Handler> *, ACE_SYNCH_RW_MUTEX> +#pragma instantiate ACE_Svc_Handler<ACE_SPIPE_STREAM, ACE_NULL_SYNCH> +#pragma instantiate ACE_Svc_Tuple<Peer_Handler> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + |