Performs non-blocking connects on behalf of the Connector. More...
#include <Connector.h>
Public Member Functions | |
ACE_NonBlocking_Connect_Handler (ACE_Connector_Base< SVC_HANDLER > &connector, SVC_HANDLER *, long timer_id) | |
Constructor. | |
~ACE_NonBlocking_Connect_Handler (void) | |
Destructor. | |
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) |
Should Reactor resume us if we have been suspended before the upcall? | |
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. | |
SVC_HANDLER * | cleanup_svc_handler_ |
Same as svc_handler_ if svc_handler_ is reference counted. | |
long | timer_id_ |
Associated timer id. |
Performs non-blocking connects on behalf of the Connector.
Definition at line 61 of file Connector.h.
ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::ACE_NonBlocking_Connect_Handler | ( | ACE_Connector_Base< SVC_HANDLER > & | connector, | |
SVC_HANDLER * | sh, | |||
long | timer_id | |||
) |
Constructor.
Definition at line 22 of file Connector.cpp.
: connector_ (connector) , svc_handler_ (sh) , cleanup_svc_handler_ (0) , timer_id_ (id) { ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler"); this->reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); if (this->svc_handler_ != 0 && this->svc_handler_->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED) { // If SVC_HANDLER is reference counted then NBCH holds a reference // in cleanup_svc_handle_ which is both a pointer to SVC_HANDLER // and a flag that triggers remove_reference in NBCH destructor. this->cleanup_svc_handler_ = sh; this->cleanup_svc_handler_->add_reference (); } }
ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::~ACE_NonBlocking_Connect_Handler | ( | void | ) |
Destructor.
Definition at line 48 of file Connector.cpp.
{ if (this->cleanup_svc_handler_) { this->cleanup_svc_handler_->remove_reference (); } }
bool ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::close | ( | SVC_HANDLER *& | sh | ) |
Close up and return underlying SVC_HANDLER through sh
.
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 sh
does not have any connection to the return value. The argument will return a valid svc_handler object if a valid one exists within the object. Returning a valid svc_handler pointer also invalidates the svc_handler contained in this object.
Definition at line 91 of file Connector.cpp.
{ // Make sure that we haven't already initialized the Svc_Handler. if (!this->svc_handler_) return false; { // Exclusive access to the Reactor. ACE_GUARD_RETURN (ACE_Lock, ace_mon, this->reactor ()->lock (), 0); // Double check. if (!this->svc_handler_) return false; // Remember the Svc_Handler. sh = this->svc_handler_; ACE_HANDLE h = sh->get_handle (); this->svc_handler_ = 0; // Remove this handle from the set of non-blocking handles // in the Connector. this->connector_.non_blocking_handles ().remove (h); // Cancel timer. if (this->reactor ()->cancel_timer (this->timer_id (), 0, 0) == -1) return false; // Remove from Reactor. if (this->reactor ()->remove_handler ( h, ACE_Event_Handler::ALL_EVENTS_MASK) == -1) return false; } return true; }
void ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::dump | ( | void | ) | const |
Dump the state of an object.
Definition at line 78 of file Connector.cpp.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("svc_handler_ = %x"), this->svc_handler_)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\ntimer_id_ = %d"), this->timer_id_)); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ }
void ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle | ( | ACE_HANDLE | ) |
Set handle.
ACE_HANDLE ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle | ( | void | ) |
Get handle.
int ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_exception | ( | ACE_HANDLE | fd | ) | [virtual] |
Called by ACE_Reactor when asynchronous connections suceeds (on some platforms only).
Reimplemented from ACE_Event_Handler.
Definition at line 196 of file Connector.cpp.
{ // On Win32, the except mask must also be set for asynchronous // connects. ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_exception"); return this->handle_output (h); }
int ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_input | ( | ACE_HANDLE | ) | [virtual] |
Called by ACE_Reactor when asynchronous connections fail.
Reimplemented from ACE_Event_Handler.
Definition at line 158 of file Connector.cpp.
{ // Called when a failure occurs during asynchronous connection // establishment. ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_input"); SVC_HANDLER *svc_handler = 0; int const retval = this->close (svc_handler) ? 0 : -1; // Close Svc_Handler. if (svc_handler != 0) { svc_handler->close (NORMAL_CLOSE_OPERATION); } return retval; }
int ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_output | ( | ACE_HANDLE | handle | ) | [virtual] |
Called by ACE_Reactor when asynchronous connections succeed.
Reimplemented from ACE_Event_Handler.
Definition at line 177 of file Connector.cpp.
{ // Called when a connection is establishment asynchronous. ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_output"); // Grab the connector ref before smashing ourselves in close(). ACE_Connector_Base<SVC_HANDLER> &connector = this->connector_; SVC_HANDLER *svc_handler = 0; int const retval = this->close (svc_handler) ? 0 : -1; if (svc_handler != 0) { connector.initialize_svc_handler (handle, svc_handler); } return retval; }
int ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::handle_timeout | ( | const ACE_Time_Value & | tv, | |
const void * | arg | |||
) | [virtual] |
This method is called if a connection times out before completing.
Reimplemented from ACE_Event_Handler.
Definition at line 136 of file Connector.cpp.
{ // This method is called if a connection times out before completing. ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout"); SVC_HANDLER *svc_handler = 0; int const retval = this->close (svc_handler) ? 0 : -1; // Forward to the SVC_HANDLER the <arg> that was passed in as a // magic cookie during ACE_Connector::connect(). This gives the // SVC_HANDLER an opportunity to take corrective action (e.g., wait // a few milliseconds and try to reconnect again. if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1) svc_handler->handle_close (svc_handler->get_handle (), ACE_Event_Handler::TIMER_MASK); return retval; }
int ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::resume_handler | ( | void | ) | [virtual] |
Should Reactor resume us if we have been suspended before the upcall?
Reimplemented from ACE_Event_Handler.
Definition at line 205 of file Connector.cpp.
{
return ACE_Event_Handler::ACE_EVENT_HANDLER_NOT_RESUMED;
}
SVC_HANDLER * ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::svc_handler | ( | void | ) |
Get SVC_HANDLER.
Definition at line 57 of file Connector.cpp.
{ ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::svc_handler"); return this->svc_handler_; }
void ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id | ( | long | timer_id | ) |
Set timer id.
Definition at line 71 of file Connector.cpp.
long ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id | ( | void | ) |
Get timer id.
Definition at line 64 of file Connector.cpp.
ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Definition at line 123 of file Connector.h.
SVC_HANDLER* ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::cleanup_svc_handler_ [private] |
Same as svc_handler_ if svc_handler_ is reference counted.
Definition at line 134 of file Connector.h.
ACE_Connector_Base<SVC_HANDLER>& ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::connector_ [private] |
Connector base.
Definition at line 128 of file Connector.h.
SVC_HANDLER* ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::svc_handler_ [private] |
Associated SVC_HANDLER.
Definition at line 131 of file Connector.h.
long ACE_NonBlocking_Connect_Handler< SVC_HANDLER >::timer_id_ [private] |
Associated timer id.
Definition at line 137 of file Connector.h.