#include <Connector.h>
Inheritance diagram for ACE_NonBlocking_Connect_Handler< SVC_HANDLER >:
Public Member Functions | |
ACE_NonBlocking_Connect_Handler (ACE_Connector_Base< SVC_HANDLER > &connector, SVC_HANDLER *, long timer_id) | |
bool | close (SVC_HANDLER *&sh) |
Close up and return underlying SVC_HANDLER through sh . | |
SVC_HANDLER * | svc_handler (void) |
Get SVC_HANDLER. | |
ACE_HANDLE | handle (void) |
Get handle. | |
void | handle (ACE_HANDLE) |
Set handle. | |
long | timer_id (void) |
Get timer id. | |
void | timer_id (long timer_id) |
Set timer id. | |
virtual int | handle_input (ACE_HANDLE) |
Called by ACE_Reactor when asynchronous connections fail. | |
virtual int | handle_output (ACE_HANDLE) |
Called by ACE_Reactor when asynchronous connections succeed. | |
virtual int | handle_exception (ACE_HANDLE fd) |
virtual int | handle_timeout (const ACE_Time_Value &tv, const void *arg) |
virtual int | resume_handler (void) |
void | dump (void) const |
Dump the state of an object. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Private Attributes | |
ACE_Connector_Base< SVC_HANDLER > & | connector_ |
Connector base. | |
SVC_HANDLER * | svc_handler_ |
Associated SVC_HANDLER. | |
long | timer_id_ |
Associated timer id. |
Definition at line 61 of file Connector.h.
|
Definition at line 22 of file Connector.cpp. References ACE_TRACE.
00025 : connector_ (connector) 00026 , svc_handler_ (sh) 00027 , timer_id_ (id) 00028 { 00029 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler"); 00030 00031 this->reference_counting_policy ().value 00032 (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); 00033 } |
|
Close up and return underlying SVC_HANDLER through
If the return value is true the close was performed succesfully, implying that this object was removed from the reactor and thereby (by means of reference counting decremented to 0) deleted. If the return value is false, the close was not successful. The Definition at line 70 of file Connector.cpp. References ACE_GUARD_RETURN, ACE_Reactor::cancel_timer(), ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::connector_, ACE_Event_Handler::reactor(), and ACE_Reactor::remove_handler(). Referenced by ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_input(), and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_output().
00071 { 00072 // Make sure that we haven't already initialized the Svc_Handler. 00073 if (!this->svc_handler_) 00074 return false; 00075 00076 { 00077 // Exclusive access to the Reactor. 00078 ACE_GUARD_RETURN (ACE_Lock, 00079 ace_mon, 00080 this->reactor ()->lock (), 00081 0); 00082 00083 // Double check. 00084 if (!this->svc_handler_) 00085 return false; 00086 00087 // Remember the Svc_Handler. 00088 sh = this->svc_handler_; 00089 ACE_HANDLE h = sh->get_handle (); 00090 this->svc_handler_ = 0; 00091 00092 // Remove this handle from the set of non-blocking handles 00093 // in the Connector. 00094 this->connector_.non_blocking_handles ().remove (h); 00095 00096 // Cancel timer. 00097 if (this->reactor ()->cancel_timer (this->timer_id (), 00098 0, 00099 0) == -1) 00100 return false; 00101 00102 // Remove from Reactor. 00103 if (this->reactor ()->remove_handler ( 00104 h, 00105 ACE_Event_Handler::ALL_EVENTS_MASK) == -1) 00106 return false; 00107 } 00108 00109 return true; 00110 } |
|
Dump the state of an object.
Definition at line 57 of file Connector.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, and LM_DEBUG.
00058 { 00059 #if defined (ACE_HAS_DUMP) 00060 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::dump"); 00061 00062 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00063 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("svc_handler_ = %x"), this->svc_handler_)); 00064 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d"), this->timer_id_)); 00065 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00066 #endif /* ACE_HAS_DUMP */ 00067 } |
|
Set handle.
|
|
Get handle.
|
|
Called by ACE_Reactor when asynchronous connections suceeds (on some platforms only). Reimplemented from ACE_Event_Handler. Definition at line 171 of file Connector.cpp. References ACE_TRACE, and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_output().
00172 { 00173 // On Win32, the except mask must also be set for asynchronous 00174 // connects. 00175 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_exception"); 00176 return this->handle_output (h); 00177 } |
|
Called by ACE_Reactor when asynchronous connections fail.
Reimplemented from ACE_Event_Handler. Definition at line 137 of file Connector.cpp. References ACE_TRACE, ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::close(), and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::svc_handler().
00138 { 00139 // Called when a failure occurs during asynchronous connection 00140 // establishment. 00141 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_input"); 00142 00143 SVC_HANDLER *svc_handler = 0; 00144 int const retval = this->close (svc_handler) ? 0 : -1; 00145 00146 // Close Svc_Handler. 00147 if (svc_handler != 0) 00148 svc_handler->close (0); 00149 00150 return retval; 00151 } |
|
Called by ACE_Reactor when asynchronous connections succeed.
Reimplemented from ACE_Event_Handler. Definition at line 154 of file Connector.cpp. References ACE_TRACE, ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::close(), ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::connector_, ACE_Connector_Base< SVC_HANDLER >::initialize_svc_handler(), and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::svc_handler(). Referenced by ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_exception().
00155 { 00156 // Called when a connection is establishment asynchronous. 00157 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_output"); 00158 00159 // Grab the connector ref before smashing ourselves in close(). 00160 ACE_Connector_Base<SVC_HANDLER> &connector = this->connector_; 00161 SVC_HANDLER *svc_handler = 0; 00162 int const retval = this->close (svc_handler) ? 0 : -1; 00163 00164 if (svc_handler != 0) 00165 connector.initialize_svc_handler (handle, svc_handler); 00166 00167 return retval; 00168 } |
|
This method is called if a connection times out before completing. Reimplemented from ACE_Event_Handler. Definition at line 115 of file Connector.cpp. References ACE_TRACE.
00117 { 00118 // This method is called if a connection times out before completing. 00119 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout"); 00120 00121 SVC_HANDLER *svc_handler = 0; 00122 int retval = this->close (svc_handler) ? 0 : -1; 00123 00124 // Forward to the SVC_HANDLER the <arg> that was passed in as a 00125 // magic cookie during ACE_Connector::connect(). This gives the 00126 // SVC_HANDLER an opportunity to take corrective action (e.g., wait 00127 // a few milliseconds and try to reconnect again. 00128 if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1) 00129 svc_handler->handle_close (svc_handler->get_handle (), 00130 ACE_Event_Handler::TIMER_MASK); 00131 00132 return retval; 00133 } |
|
Should Reactor resume us if we have been suspended before the upcall? Reimplemented from ACE_Event_Handler. Definition at line 180 of file Connector.cpp.
00181 { 00182 return ACE_Event_Handler::ACE_EVENT_HANDLER_NOT_RESUMED; 00183 } |
|
Get SVC_HANDLER.
Definition at line 36 of file Connector.cpp. References ACE_TRACE. Referenced by ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_input(), and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_output().
00037 { 00038 ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::svc_handler"); 00039 return this->svc_handler_; 00040 } |
|
Set timer id.
Definition at line 50 of file Connector.cpp. References ACE_TRACE, and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id_.
|
|
Get timer id.
Definition at line 43 of file Connector.cpp. References ACE_TRACE, and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id_.
|
|
Declare the dynamic allocation hooks.
Definition at line 124 of file Connector.h. |
|
Connector base.
Definition at line 129 of file Connector.h. Referenced by ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::close(), and ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_output(). |
|
Associated SVC_HANDLER.
Definition at line 132 of file Connector.h. |
|
Associated timer id.
Definition at line 135 of file Connector.h. Referenced by ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id(). |