From 8cd7cd2d207337d4d6b736d35864875503a89cde Mon Sep 17 00:00:00 2001 From: schmidt Date: Thu, 4 Apr 2013 16:29:51 +0000 Subject: ChangeLogTag:Thu --- .../Connection/non_blocking/CPP-acceptor.cpp | 67 ++++++--------- .../Connection/non_blocking/CPP-acceptor.h | 15 ++-- .../Connection/non_blocking/CPP-connector.cpp | 97 +++++++++------------- .../Connection/non_blocking/CPP-connector.h | 12 +-- 4 files changed, 80 insertions(+), 111 deletions(-) diff --git a/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp b/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp index 608745d721f..314c004cdb4 100644 --- a/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp +++ b/ACE/examples/Connection/non_blocking/CPP-acceptor.cpp @@ -9,23 +9,14 @@ #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" - - -#define PR_ST_1 ACE_PEER_STREAM_1 -#define PR_ST_2 ACE_PEER_STREAM_2 -#define PR_AC_1 ACE_PEER_ACCEPTOR_1 -#define PR_AC_2 ACE_PEER_ACCEPTOR_2 -#define PR_AD ACE_PEER_STREAM_ADDR -#define SVH SVC_HANDLER - -template -Svc_Handler::Svc_Handler (ACE_Reactor *r) +template +Svc_Handler::Svc_Handler (ACE_Reactor *r) : SVC_HANDLER (0, 0, r) { } -template int -Svc_Handler::close (u_long) +template int +Svc_Handler::close (u_long) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("calling Svc_Handler close\n"))); @@ -34,10 +25,10 @@ Svc_Handler::close (u_long) return 0; } -template int -Svc_Handler::open (void *) +template int +Svc_Handler::open (void *) { - PR_AD client_addr; + typename PEER_STREAM::PEER_ADDR client_addr; ACE_TCHAR buf[BUFSIZ]; if (this->peer ().get_remote_addr (client_addr) == -1) @@ -64,8 +55,8 @@ Svc_Handler::open (void *) // Receive and process the data from the client. -template int -Svc_Handler::handle_input (ACE_HANDLE) +template int +Svc_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; @@ -94,16 +85,16 @@ Svc_Handler::handle_input (ACE_HANDLE) return 0; } -template int -Svc_Handler::handle_timeout (const ACE_Time_Value &, +template int +Svc_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"), ACE_TEXT ("handle_timeout"))); return 0; } -template int -IPC_Server::init (int argc, ACE_TCHAR *argv[]) +template int +IPC_Server::init (int argc, ACE_TCHAR *argv[]) { const ACE_TCHAR *local_addr = argc > 1 ? argv[1] @@ -155,25 +146,25 @@ IPC_Server::init (int argc, ACE_TCHAR *argv[]) return 0; } -template -IPC_Server::IPC_Server (void) +template +IPC_Server::IPC_Server (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } -template int -IPC_Server::fini (void) +template int +IPC_Server::fini (void) { return 0; } -template -IPC_Server::~IPC_Server (void) +template +IPC_Server::~IPC_Server (void) { } -template int -IPC_Server::handle_close (ACE_HANDLE handle, +template int +IPC_Server::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask mask) { ACE_UNUSED_ARG (handle); @@ -186,8 +177,8 @@ IPC_Server::handle_close (ACE_HANDLE handle, // Run the interative service. -template int -IPC_Server::svc (void) +template int +IPC_Server::svc (void) { ACE_TCHAR buf[BUFSIZ]; @@ -207,9 +198,9 @@ IPC_Server::svc (void) while (ACE_Reactor::event_loop_done () == 0) { - SVH sh (this->reactor ()); + SVC_HANDLER sh (this->reactor ()); - // Create a new endpoint, which performs all processing in + // Create a new endpoint, which performs all processing in // its method (note no automatic restart if errno == // EINTR). @@ -230,7 +221,7 @@ IPC_Server::svc (void) this->acceptor ().get_handle ())); } - // 's destructor closes the stream implicitly but the + // 's destructor closes the stream implicitly but the // listening endpoint stays open. } @@ -238,10 +229,4 @@ IPC_Server::svc (void) return 0; } -#undef PR_ST_1 -#undef PR_ST_2 -#undef PR_AC_1 -#undef PR_AC_2 -#undef PR_AD -#undef SVH #endif /* CPP_ACCEPTOR_C */ diff --git a/ACE/examples/Connection/non_blocking/CPP-acceptor.h b/ACE/examples/Connection/non_blocking/CPP-acceptor.h index c06caf50b48..7d3ccfd4be4 100644 --- a/ACE/examples/Connection/non_blocking/CPP-acceptor.h +++ b/ACE/examples/Connection/non_blocking/CPP-acceptor.h @@ -13,9 +13,8 @@ #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" - -template -class Svc_Handler : public ACE_Svc_Handler +template +class Svc_Handler : public ACE_Svc_Handler { // = TITLE // This class does the work once the has @@ -37,12 +36,12 @@ public: // Handles acceptor timeouts. private: - typedef ACE_Svc_Handler + typedef ACE_Svc_Handler SVC_HANDLER; }; -template -class IPC_Server : public ACE_Oneshot_Acceptor +template +class IPC_Server : public ACE_Oneshot_Acceptor { // = TITLE // This class illustrates how the works. @@ -71,10 +70,10 @@ public: // Run the interative service. private: - typedef ACE_Oneshot_Acceptor + typedef ACE_Oneshot_Acceptor inherited; - ACE_PEER_ACCEPTOR_ADDR server_addr_; + typename PEER_ACCEPTOR::PEER_ADDR server_addr_; // Address of this server. ACE_Synch_Options options_; diff --git a/ACE/examples/Connection/non_blocking/CPP-connector.cpp b/ACE/examples/Connection/non_blocking/CPP-connector.cpp index a856a88f8af..eb92e82bd2b 100644 --- a/ACE/examples/Connection/non_blocking/CPP-connector.cpp +++ b/ACE/examples/Connection/non_blocking/CPP-connector.cpp @@ -8,29 +8,20 @@ #include "ace/OS_NS_unistd.h" #include "ace/Signal.h" - - -#define PR_ST_1 ACE_PEER_STREAM_1 -#define PR_ST_2 ACE_PEER_STREAM_2 -#define PR_CO_1 ACE_PEER_CONNECTOR_1 -#define PR_CO_2 ACE_PEER_CONNECTOR_2 -#define PR_AD ACE_PEER_CONNECTOR_ADDR -#define SVH SVC_HANDLER - -template -Peer_Handler::Peer_Handler (ACE_Reactor *r) - : action_ (&Peer_Handler::uninitialized) +template +Peer_Handler::Peer_Handler (ACE_Reactor *r) + : action_ (&Peer_Handler::uninitialized) { this->reactor (r); } -template int -Peer_Handler::open (void *) +template int +Peer_Handler::open (void *) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("activating %d\n"), this->peer ().get_handle ())); - this->action_ = &Peer_Handler::connected; + this->action_ = &Peer_Handler::connected; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("please enter input..: "))); @@ -59,8 +50,8 @@ Peer_Handler::open (void *) return 0; } -template int -Peer_Handler::close (u_long) +template int +Peer_Handler::close (u_long) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect not successful: ending reactor event loop\n"))); @@ -68,15 +59,15 @@ Peer_Handler::close (u_long) return 0; } -template int -Peer_Handler::uninitialized (void) +template int +Peer_Handler::uninitialized (void) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("uninitialized!\n"))); return 0; } -template int -Peer_Handler::connected (void) +template int +Peer_Handler::connected (void) { char buf[BUFSIZ]; @@ -106,8 +97,8 @@ Peer_Handler::connected (void) } } -template int -Peer_Handler::stdio (void) +template int +Peer_Handler::stdio (void) { char buf[BUFSIZ]; @@ -131,26 +122,26 @@ Peer_Handler::stdio (void) return -1; } -template int -Peer_Handler::handle_timeout (const ACE_Time_Value &, +template int +Peer_Handler::handle_timeout (const ACE_Time_Value &, const void *) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Connect timedout. "))); return this->close (); } -template int -Peer_Handler::handle_output (ACE_HANDLE) +template int +Peer_Handler::handle_output (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_output\n"))); return (this->*action_) (); } -template int -Peer_Handler::handle_signal (int, - siginfo_t *, - ucontext_t *) +template int +Peer_Handler::handle_signal (int, + siginfo_t *, + ucontext_t *) { // @@ Note that this code is not portable to all OS platforms since // it uses print statements within signal handler context. @@ -159,16 +150,16 @@ Peer_Handler::handle_signal (int, return (this->*action_) (); } -template int -Peer_Handler::handle_input (ACE_HANDLE) +template int +Peer_Handler::handle_input (ACE_HANDLE) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("in handle_input\n"))); return (this->*action_) (); } -template int -Peer_Handler::handle_close (ACE_HANDLE h, +template int +Peer_Handler::handle_close (ACE_HANDLE h, ACE_Reactor_Mask mask) { ACE_DEBUG ((LM_DEBUG, @@ -176,7 +167,7 @@ Peer_Handler::handle_close (ACE_HANDLE h, h, mask)); - if (this->action_ == &Peer_Handler::stdio) + if (this->action_ == &Peer_Handler::stdio) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to closed state\n"))); this->reactor ()->end_reactor_event_loop (); @@ -184,7 +175,7 @@ Peer_Handler::handle_close (ACE_HANDLE h, else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("moving to stdio state\n"))); - this->action_ = &Peer_Handler::stdio; + this->action_ = &Peer_Handler::stdio; this->peer ().close (); ACE_OS::rewind (stdin); @@ -208,8 +199,8 @@ Peer_Handler::handle_close (ACE_HANDLE h, return 0; } -template int -IPC_Client::svc (void) +template int +IPC_Client::svc (void) { if (this->reactor ()) this->reactor ()->run_reactor_event_loop (); @@ -217,20 +208,20 @@ IPC_Client::svc (void) return 0; } -template int -IPC_Client::fini (void) +template int +IPC_Client::fini (void) { return 0; } -template -IPC_Client::IPC_Client (void) +template +IPC_Client::IPC_Client (void) : done_handler_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop)) { } -template int -IPC_Client::init (int argc, ACE_TCHAR *argv[]) +template int +IPC_Client::init (int argc, ACE_TCHAR *argv[]) { // Call down to the CONNECTOR's open() method to do the // initialization. @@ -251,13 +242,13 @@ IPC_Client::init (int argc, ACE_TCHAR *argv[]) ACE_TEXT ("%p\n"), ACE_TEXT ("register_handler")), -1); - PR_AD remote_addr (r_addr); + typename PEER_CONNECTOR::PEER_ADDR remote_addr (r_addr); this->options_.set (ACE_Synch_Options::USE_REACTOR, timeout); - SVH *sh; + SVC_HANDLER *sh; ACE_NEW_RETURN (sh, - SVH (this->reactor ()), + SVC_HANDLER (this->reactor ()), -1); // Connect to the peer. @@ -273,15 +264,9 @@ IPC_Client::init (int argc, ACE_TCHAR *argv[]) return 0; } -template -IPC_Client::~IPC_Client (void) +template +IPC_Client::~IPC_Client (void) { } -#undef PR_ST_1 -#undef PR_ST_2 -#undef PR_CO_1 -#undef PR_CO_2 -#undef PR_AD -#undef SVH #endif /* CPP_CONNECTOR_C */ diff --git a/ACE/examples/Connection/non_blocking/CPP-connector.h b/ACE/examples/Connection/non_blocking/CPP-connector.h index 86ce63493f0..5f11cbf27e0 100644 --- a/ACE/examples/Connection/non_blocking/CPP-connector.h +++ b/ACE/examples/Connection/non_blocking/CPP-connector.h @@ -14,8 +14,8 @@ #include "ace/Svc_Handler.h" #include "ace/Sig_Adapter.h" -template -class Peer_Handler : public ACE_Svc_Handler +template +class Peer_Handler : public ACE_Svc_Handler { // = TITLE // Handles communication with the server. @@ -48,12 +48,12 @@ protected: int connected (void); int stdio (void); - int (Peer_Handler::*action_) (void); + int (Peer_Handler::*action_) (void); // Keeps track of which state we are in. }; -template -class IPC_Client : public ACE_Connector +template +class IPC_Client : public ACE_Connector { // = TITLE // This class illustrates how the works. @@ -76,7 +76,7 @@ public: // Run the svc. private: - typedef ACE_Connector + typedef ACE_Connector inherited; ACE_Synch_Options options_; -- cgit v1.2.1