ACE_Strategy_Acceptor< SVC_HANDLER, > Class Template Reference

Abstract factory for creating a service handler (SVC_HANDLER), accepting into the SVC_HANDLER, and activating the SVC_HANDLER. More...

#include <Acceptor.h>

Inheritance diagram for ACE_Strategy_Acceptor< SVC_HANDLER, >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Strategy_Acceptor< SVC_HANDLER, >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
creation_strategy_type
typedef ACE_Accept_Strategy<
SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > 
accept_strategy_type
typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
concurrency_strategy_type
typedef ACE_Scheduling_Strategy<
SVC_HANDLER > 
scheduling_strategy_type
typedef ACE_Acceptor< SVC_HANDLER,
ACE_PEER_ACCEPTOR_2 > 
base_type
typedef ACE_Creation_Strategy<
SVC_HANDLER > 
CREATION_STRATEGY
typedef ACE_Accept_Strategy<
SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > 
ACCEPT_STRATEGY
typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
CONCURRENCY_STRATEGY
typedef ACE_Scheduling_Strategy<
SVC_HANDLER > 
SCHEDULING_STRATEGY

Public Member Functions

 ACE_Strategy_Acceptor (const ACE_TCHAR service_name[]=0, const ACE_TCHAR service_description[]=0, int use_select=1, int reuse_addr=1)
 Default constructor.

 ACE_Strategy_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *=ACE_Reactor::instance(), ACE_Creation_Strategy< SVC_HANDLER > *=0, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *=0, ACE_Concurrency_Strategy< SVC_HANDLER > *=0, ACE_Scheduling_Strategy< SVC_HANDLER > *=0, const ACE_TCHAR service_name[]=0, const ACE_TCHAR service_description[]=0, int use_select=1, int reuse_addr=1)
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *reactor, int flags=0, int use_select=1, int reuse_addr=1)
virtual int open (const ACE_PEER_ACCEPTOR_ADDR &, ACE_Reactor *=ACE_Reactor::instance(), ACE_Creation_Strategy< SVC_HANDLER > *=0, ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *=0, ACE_Concurrency_Strategy< SVC_HANDLER > *=0, ACE_Scheduling_Strategy< SVC_HANDLER > *=0, const ACE_TCHAR *service_name=0, const ACE_TCHAR *service_description=0, int use_select=1, int reuse_addr=1)
virtual ~ACE_Strategy_Acceptor (void)
 Close down the Strategy_Acceptor's resources.

virtual operator ACE_PEER_ACCEPTOR & () const
 Return the underlying PEER_ACCEPTOR object.

virtual ACE_PEER_ACCEPTOR & acceptor (void) const
 Return the underlying PEER_ACCEPTOR object.

virtual ACE_HANDLE get_handle (void) const
 Returns the listening acceptor's {ACE_HANDLE}.

void dump (void) const
 Dump the state of an object.

virtual int suspend (void)
virtual int resume (void)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

virtual int fini (void)
 Calls {handle_close} when dynamically unlinked.

virtual int info (ACE_TCHAR **buf, size_t) const
 Default version returns address info in {buf}.

virtual int make_svc_handler (SVC_HANDLER *&)
virtual int accept_svc_handler (SVC_HANDLER *svc_handler)
virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
virtual int handle_close (ACE_HANDLE=ACE_INVALID_HANDLE, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
virtual int handle_signal (int signum, siginfo_t *, ucontext_t *)
 Handle SIGINT.


Protected Attributes

CREATION_STRATEGYcreation_strategy_
 Creation strategy for an Acceptor.

int delete_creation_strategy_
ACCEPT_STRATEGYaccept_strategy_
 Accept strategy for an {Acceptor}.

int delete_accept_strategy_
CONCURRENCY_STRATEGYconcurrency_strategy_
 Concurrency strategy for an {Acceptor}.

int delete_concurrency_strategy_
SCHEDULING_STRATEGYscheduling_strategy_
 Scheduling strategy for an {Acceptor}.

int delete_scheduling_strategy_
ACE_TCHARservice_name_
 Name of the service.

ACE_TCHARservice_description_
 Description of the service.

ACE_PEER_ACCEPTOR_ADDR service_addr_

Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Strategy_Acceptor< SVC_HANDLER, >

Abstract factory for creating a service handler (SVC_HANDLER), accepting into the SVC_HANDLER, and activating the SVC_HANDLER.

Implements a flexible and extensible set of strategies for passively establishing connections with clients. There are three main strategies: (1) creating a SVC_HANDLER, (2) passively accepting a new connection from a client into the SVC_HANDLER, and (3) activating the SVC_HANDLER with a particular concurrency mechanism.

Definition at line 270 of file Acceptor.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::ACCEPT_STRATEGY
 

Definition at line 288 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::open().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_type
 

Definition at line 279 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2> ACE_Strategy_Acceptor< SVC_HANDLER, >::base_type
 

Definition at line 284 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CONCURRENCY_STRATEGY
 

Definition at line 289 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::open().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_type
 

Definition at line 281 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::CREATION_STRATEGY
 

Definition at line 287 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::open().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_type
 

Definition at line 277 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::SCHEDULING_STRATEGY
 

Definition at line 290 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::open().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_Scheduling_Strategy<SVC_HANDLER> ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_type
 

Definition at line 282 of file Acceptor.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor const ACE_TCHAR  service_name[] = 0,
const ACE_TCHAR  service_description[] = 0,
int  use_select = 1,
int  reuse_addr = 1
 

Default constructor.

Definition at line 623 of file Acceptor.cpp.

References ACE_ALLOCATOR, ACE_TCHAR, and ACE_TRACE.

00627     : creation_strategy_ (0),
00628       delete_creation_strategy_ (0),
00629       accept_strategy_ (0),
00630       delete_accept_strategy_ (0),
00631       concurrency_strategy_ (0),
00632       delete_concurrency_strategy_ (0),
00633       scheduling_strategy_ (0),
00634       delete_scheduling_strategy_ (0),
00635       service_name_ (0),
00636       service_description_ (0)
00637 {
00638   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00639 
00640   if (service_name != 0)
00641     ACE_ALLOCATOR (this->service_name_,
00642                    ACE_OS::strdup (service_name));
00643   if (service_description != 0)
00644     ACE_ALLOCATOR (this->service_description_,
00645                    ACE_OS::strdup (service_description));
00646   this->use_select_ = use_select;
00647   this->reuse_addr_ = reuse_addr;
00648 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_Strategy_Acceptor const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
ACE_Reactor = ACE_Reactor::instance(),
ACE_Creation_Strategy< SVC_HANDLER > *  = 0,
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *  = 0,
ACE_Concurrency_Strategy< SVC_HANDLER > *  = 0,
ACE_Scheduling_Strategy< SVC_HANDLER > *  = 0,
const ACE_TCHAR  service_name[] = 0,
const ACE_TCHAR  service_description[] = 0,
int  use_select = 1,
int  reuse_addr = 1
 

Initialize the appropriate strategies for creation, passive connection acceptance, and concurrency, and then register {this} with the Reactor and listen for connection requests at the designated {local_addr}.

Definition at line 652 of file Acceptor.cpp.

References ACE_ERROR, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TEXT, ACE_TRACE, and LM_ERROR.

00662     : creation_strategy_ (0),
00663       delete_creation_strategy_ (0),
00664       accept_strategy_ (0),
00665       delete_accept_strategy_ (0),
00666       concurrency_strategy_ (0),
00667       delete_concurrency_strategy_ (0),
00668       scheduling_strategy_ (0),
00669       delete_scheduling_strategy_ (0),
00670       service_name_ (0),
00671       service_description_ (0)
00672 {
00673   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor");
00674 
00675   if (this->open (addr,
00676                   reactor,
00677                   cre_s,
00678                   acc_s,
00679                   con_s,
00680                   sch_s,
00681                   service_name,
00682                   service_description,
00683                   use_select,
00684                   reuse_addr) == -1)
00685     ACE_ERROR ((LM_ERROR,
00686                 ACE_TEXT ("%p\n"),
00687                 ACE_TEXT ("ACE_Strategy_Acceptor::ACE_Strategy_Acceptor")));
00688 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor void   )  [virtual]
 

Close down the Strategy_Acceptor's resources.

Definition at line 783 of file Acceptor.cpp.

References ACE_TRACE, ACE_OS::free(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

00784 {
00785   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Strategy_Acceptor");
00786   ACE_OS::free ((void *) this->service_name_);
00787   ACE_OS::free ((void *) this->service_description_);
00788   this->handle_close ();
00789 }


Member Function Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_svc_handler SVC_HANDLER *  svc_handler  )  [protected, virtual]
 

Bridge method for accepting the new connection into the {SVC_HANDLER}. The default behavior delegates to the {PEER_ACCEPTOR::accept} in the {Acceptor_Strategy}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 758 of file Acceptor.cpp.

References ACE_TRACE.

00759 {
00760   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler");
00761   return this->accept_strategy_->accept_svc_handler (svc_handler);
00762 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR & ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor void   )  const [virtual]
 

Return the underlying PEER_ACCEPTOR object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 484 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::info().

00485 {
00486   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
00487   return this->accept_strategy_->acceptor ();
00488 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::activate_svc_handler SVC_HANDLER *  svc_handler  )  [protected, virtual]
 

Bridge method for activating a {SVC_HANDLER} with the appropriate concurrency strategy. The default behavior of this method is to activate the {SVC_HANDLER} by calling its {open} method (which allows the {SVC_HANDLER} to define its own concurrency strategy). However, subclasses can override this strategy to do more sophisticated concurrency activations (such as creating the {SVC_HANDLER} as an "active object" via multi-threading or multi-processing).

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 774 of file Acceptor.cpp.

References ACE_TRACE.

00775 {
00776   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
00777   return this->concurrency_strategy_->activate_svc_handler
00778     (svc_handler,
00779      (void *) this);
00780 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
void ACE_Strategy_Acceptor< SVC_HANDLER, >::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 459 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_, ACE_Scheduling_Strategy< SVC_HANDLER >::dump(), ACE_Concurrency_Strategy< SVC_HANDLER >::dump(), ACE_Accept_Strategy< SVC_HANDLER, >::dump(), ACE_Creation_Strategy< SVC_HANDLER >::dump(), ACE_Acceptor< SVC_HANDLER, >::dump(), LM_DEBUG, ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_, and ACE_Strategy_Acceptor< SVC_HANDLER, >::service_addr_.

00460 {
00461 #if defined (ACE_HAS_DUMP)
00462   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
00463 
00464   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00465   ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump ();
00466   this->creation_strategy_->dump ();
00467   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_creation_strategy_ = %d"), delete_creation_strategy_));
00468   this->accept_strategy_->dump ();
00469   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_accept_strategy_ = %d"), delete_accept_strategy_));
00470   this->concurrency_strategy_->dump ();
00471   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_concurrency_strategy_ = %d"), delete_concurrency_strategy_));
00472   this->scheduling_strategy_->dump ();
00473   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_scheduling_strategy_ = %d"), delete_scheduling_strategy_));
00474   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_name_ = %s"),
00475               this->service_name_ == 0 ? ACE_TEXT ("<unknown>") : this->service_name_));
00476   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nservice_description_ = %s"),
00477               this->service_description_ == 0 ? ACE_TEXT ("<unknown>") : this->service_description_));
00478   this->service_addr_.dump ();
00479   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00480 #endif /* ACE_HAS_DUMP */
00481 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::fini void   )  [protected, virtual]
 

Calls {handle_close} when dynamically unlinked.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 835 of file Acceptor.cpp.

References ACE_TRACE, and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

00836 {
00837   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
00838   return this->ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close ();
00839 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_HANDLE ACE_Strategy_Acceptor< SVC_HANDLER, >::get_handle void   )  const [virtual]
 

Returns the listening acceptor's {ACE_HANDLE}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 500 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_TRACE, and ACE_Accept_Strategy< SVC_HANDLER, >::get_handle().

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

00501 {
00502   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
00503   return this->accept_strategy_->get_handle ();
00504 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close ACE_HANDLE  = ACE_INVALID_HANDLE,
ACE_Reactor_Mask  = ACE_Event_Handler::ALL_EVENTS_MASK
[protected, virtual]
 

Perform termination activities when {this} is removed from the {Reactor}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 694 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Reactor_Mask, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_, ACE_Strategy_Acceptor< SVC_HANDLER, >::get_handle(), ACE_Event_Handler::reactor(), ACE_Reactor::remove_handler(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::fini(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::~ACE_Strategy_Acceptor().

00696 {
00697   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
00698   // Guard against multiple closes.
00699   if (this->reactor () != 0)
00700     {
00701       ACE_HANDLE handle = this->get_handle ();
00702 
00703       if (this->delete_creation_strategy_)
00704         delete this->creation_strategy_;
00705       this->delete_creation_strategy_ = 0;
00706       this->creation_strategy_ = 0;
00707 
00708       if (this->delete_accept_strategy_)
00709         delete this->accept_strategy_;
00710       this->delete_accept_strategy_ = 0;
00711       this->accept_strategy_ = 0;
00712 
00713       if (this->delete_concurrency_strategy_)
00714         delete this->concurrency_strategy_;
00715       this->delete_concurrency_strategy_ = 0;
00716       this->concurrency_strategy_ = 0;
00717 
00718       if (this->delete_scheduling_strategy_)
00719         delete this->scheduling_strategy_;
00720       this->delete_scheduling_strategy_ = 0;
00721       this->scheduling_strategy_ = 0;
00722 
00723       // We must use the <handle> obtained *before* we deleted the
00724       // accept_strategy_...
00725 
00726       this->reactor ()->remove_handler
00727         (handle,
00728          ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
00729 
00730       // Set the Reactor to 0 so that we don't try to close down
00731       // again.
00732       this->reactor (0);
00733     }
00734   return 0;
00735 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_signal int  signum,
siginfo_t ,
ucontext_t
[protected, virtual]
 

Handle SIGINT.

Reimplemented from ACE_Event_Handler.

Definition at line 794 of file Acceptor.cpp.

References ACE_Reactor::end_reactor_event_loop(), ACE_Reactor::instance(), and ucontext_t.

00795 {
00796   ACE_Reactor::instance()->end_reactor_event_loop ();
00797   return 0;
00798 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::info ACE_TCHAR **  buf,
size_t 
const [protected, virtual]
 

Default version returns address info in {buf}.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 801 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor(), ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TEXT, ACE_TRACE, ACE_OS::sprintf(), ACE_OS::strdup(), ACE_OS::strlen(), and ACE_OS::strsncpy().

00803 {
00804   ACE_TRACE ("ACE_Strategy_Acceptor::info");
00805 
00806   ACE_TCHAR buf[BUFSIZ];
00807   ACE_TCHAR service_addr_str[BUFSIZ];
00808   ACE_PEER_ACCEPTOR_ADDR addr;
00809 
00810   if (this->acceptor ().get_local_addr (addr) == -1)
00811     return -1;
00812   else if (addr.addr_to_string (service_addr_str,
00813                                 sizeof service_addr_str) == -1)
00814     return -1;
00815 
00816   // @@ Should add the protocol in...
00817   ACE_OS::sprintf (buf,
00818                    ACE_TEXT ("%s\t %s #%s\n"),
00819                    this->service_name_ == 0
00820                    ? ACE_TEXT ("<unknown>")
00821                    : this->service_name_,
00822                    service_addr_str,
00823                    this->service_description_ == 0
00824                    ? ACE_TEXT ("<unknown>")
00825                    : this->service_description_);
00826 
00827   if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
00828     return -1;
00829   else
00830     ACE_OS::strsncpy (*strp, buf, length);
00831   return static_cast<int> (ACE_OS::strlen (buf));
00832 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::make_svc_handler SVC_HANDLER *&   )  [protected, virtual]
 

Bridge method for creating a {SVC_HANDLER}. The strategy for creating a {SVC_HANDLER} are configured into the Acceptor via it's {creation_strategy_}. The default is to create a new {SVC_HANDLER} if {sh} == 0, else {sh} is unchanged. However, subclasses can override this policy to perform {SVC_HANDLER} creation in any way that they like (such as creating subclass instances of {SVC_HANDLER}, using a singleton, dynamically linking the handler, etc.). Returns -1 on failure, else 0.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 746 of file Acceptor.cpp.

References ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_, and ACE_Creation_Strategy< SVC_HANDLER >::make_svc_handler().

00747 {
00748   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::make_svc_handler");
00749   return this->creation_strategy_->make_svc_handler (sh);
00750 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &  ,
ACE_Reactor = ACE_Reactor::instance(),
ACE_Creation_Strategy< SVC_HANDLER > *  = 0,
ACE_Accept_Strategy< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 > *  = 0,
ACE_Concurrency_Strategy< SVC_HANDLER > *  = 0,
ACE_Scheduling_Strategy< SVC_HANDLER > *  = 0,
const ACE_TCHAR service_name = 0,
const ACE_TCHAR service_description = 0,
int  use_select = 1,
int  reuse_addr = 1
[virtual]
 

Initialize the appropriate strategies for creation, passive connection acceptance, and concurrency, and then register {this} with the Reactor and listen for connection requests at the designated {local_addr}.

Definition at line 526 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::ACCEPT_STRATEGY, ACE_ALLOCATOR_RETURN, ACE_NEW_RETURN, ACE_NONBLOCK, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::CONCURRENCY_STRATEGY, ACE_Strategy_Acceptor< SVC_HANDLER, >::CREATION_STRATEGY, and ACE_Strategy_Acceptor< SVC_HANDLER, >::SCHEDULING_STRATEGY.

00536 {
00537   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00538 
00539   if (this->service_name_ == 0 && service_name != 0)
00540     ACE_ALLOCATOR_RETURN (this->service_name_,
00541                           ACE_OS::strdup (service_name),
00542                           -1);
00543   if (this->service_description_ == 0 && service_description != 0)
00544     ACE_ALLOCATOR_RETURN (this->service_description_,
00545                           ACE_OS::strdup (service_description),
00546                           -1);
00547   this->reactor (reactor);
00548 
00549   // Must supply a valid Reactor to Acceptor::open()...
00550   if (reactor == 0)
00551     {
00552       errno = EINVAL;
00553       return -1;
00554     }
00555 
00556   // Initialize the creation strategy.
00557 
00558   if (cre_s == 0)
00559     {
00560       ACE_NEW_RETURN (cre_s,
00561                       CREATION_STRATEGY,
00562                       -1);
00563       this->delete_creation_strategy_ = 1;
00564     }
00565   this->creation_strategy_ = cre_s;
00566 
00567   // Initialize the accept strategy.
00568 
00569   if (acc_s == 0)
00570     {
00571       ACE_NEW_RETURN (acc_s,
00572                       ACCEPT_STRATEGY (this->reactor ()),
00573                       -1);
00574       this->delete_accept_strategy_ = 1;
00575     }
00576   this->accept_strategy_ = acc_s;
00577 
00578   if (this->accept_strategy_->open (local_addr, reuse_addr) == -1)
00579     return -1;
00580 
00581   // Set the peer acceptor's handle into non-blocking mode.  This is a
00582   // safe-guard against the race condition that can otherwise occur
00583   // between the time when <select> indicates that a passive-mode
00584   // socket handle is "ready" and when we call <accept>.  During this
00585   // interval, the client can shutdown the connection, in which case,
00586   // the <accept> call can hang!
00587   if (this->accept_strategy_->acceptor ().enable (ACE_NONBLOCK) != 0)
00588     return -1;
00589 
00590   // Initialize the concurrency strategy.
00591 
00592   if (con_s == 0)
00593     {
00594       ACE_NEW_RETURN (con_s,
00595                       CONCURRENCY_STRATEGY,
00596                       -1);
00597       this->delete_concurrency_strategy_ = 1;
00598     }
00599   this->concurrency_strategy_ = con_s;
00600 
00601   // Initialize the scheduling strategy.
00602 
00603   if (sch_s == 0)
00604     {
00605       ACE_NEW_RETURN (sch_s,
00606                       SCHEDULING_STRATEGY,
00607                       -1);
00608       this->delete_scheduling_strategy_ = 1;
00609     }
00610   this->scheduling_strategy_ = sch_s;
00611 
00612   this->use_select_ = use_select;
00613 
00614   return this->reactor ()->register_handler
00615     (this,
00616      ACE_Event_Handler::ACCEPT_MASK);
00617 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &  local_addr,
ACE_Reactor reactor,
int  flags = 0,
int  use_select = 1,
int  reuse_addr = 1
[virtual]
 

Open the contained PEER_ACCEPTOR object to begin listening, and register with the specified reactor for accept events.

The PEER_ACCEPTOR handle is put into non-blocking mode as a safeguard against the race condition that can otherwise occur between the time when the passive-mode socket handle is "ready" and when the actual accept call is made. During this interval, the client can shutdown the connection, in which case, the {accept} call can hang.

Parameters:
local_addr The address to listen at.
reactor Pointer to the ACE_Reactor instance to register this object with. The default is the singleton.
flags Flags to control what mode an accepted socket will be put into after it is accepted. The only legal value for this argument is ACE_NONBLOCK, which enables non-blocking mode on the accepted peer stream object in SVC_HANDLER. The default is 0.
use_select Affects behavior when called back by the reactor when a connection can be accepted. If non-zero, this object will accept all pending connections, intead of just the one that triggered the reactor callback. Uses ACE_OS::select() internally to detect any remaining acceptable connections. The default is 1.
reuse_addr Passed to the PEER_ACCEPTOR::open() method with local_addr. Generally used to request that the OS allow reuse of the listen port. The default is 1.
Return values:
0 Success
-1 Failure, errno contains an error code.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 512 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR_ADDR, and ACE_TRACE.

Referenced by ACE_Oneshot_Acceptor< SVC_HANDLER, >::open().

00517 {
00518   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00519   return this->open
00520     (local_addr, reactor, 0, 0, 0, 0, 0, 0, use_select, reuse_addr);
00521 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::operator ACE_PEER_ACCEPTOR &  )  const [virtual]
 

Return the underlying PEER_ACCEPTOR object.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 491 of file Acceptor.cpp.

References ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_, ACE_Accept_Strategy< SVC_HANDLER, >::acceptor(), and ACE_TRACE.

00492 {
00493   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
00494   return this->accept_strategy_->acceptor ();
00495 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::resume void   )  [virtual]
 

This method delegates to the {Scheduling_Strategy}'s {resume} method.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 447 of file Acceptor.cpp.

References ACE_TRACE, ACE_Scheduling_Strategy< SVC_HANDLER >::resume(), ACE_Acceptor< SVC_HANDLER, >::resume(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_.

00448 {
00449   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
00450 
00451   // First resume ourselves.
00452   if (ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume () == -1)
00453     return -1;
00454   else // Then resume the SVC_HANDLER's we've created.
00455     return this->scheduling_strategy_->resume ();
00456 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::suspend void   )  [virtual]
 

This method delegates to the {Scheduling_Strategy}'s {suspend} method.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 435 of file Acceptor.cpp.

References ACE_TRACE, ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_, ACE_Acceptor< SVC_HANDLER, >::suspend(), and ACE_Scheduling_Strategy< SVC_HANDLER >::suspend().

00436 {
00437   ACE_TRACE ("ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
00438 
00439   // First suspend the SVC_HANDLER's we've created.
00440   if (this->scheduling_strategy_->suspend () == -1)
00441     return -1;
00442   else   // Then suspend ourselves.
00443     return ACE_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend ();
00444 }


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACCEPT_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::accept_strategy_ [protected]
 

Accept strategy for an {Acceptor}.

Definition at line 467 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::acceptor(), ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), ACE_Strategy_Acceptor< SVC_HANDLER, >::get_handle(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::operator ACE_PEER_ACCEPTOR &().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Strategy_Acceptor< SVC_HANDLER, >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >.

Definition at line 390 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
CONCURRENCY_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::concurrency_strategy_ [protected]
 

Concurrency strategy for an {Acceptor}.

Definition at line 474 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
CREATION_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::creation_strategy_ [protected]
 

Creation strategy for an Acceptor.

Definition at line 460 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::make_svc_handler().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_accept_strategy_ [protected]
 

1 if {Acceptor} created the accept strategy and thus should delete it, else 0.

Definition at line 471 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_concurrency_strategy_ [protected]
 

1 if {Acceptor} created the concurrency strategy and thus should delete it, else 0.

Definition at line 478 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_creation_strategy_ [protected]
 

1 if {Acceptor} created the creation strategy and thus should delete it, else 0.

Definition at line 464 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Strategy_Acceptor< SVC_HANDLER, >::delete_scheduling_strategy_ [protected]
 

1 if {Acceptor} created the scheduling strategy and thus should delete it, else 0.

Definition at line 485 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
SCHEDULING_STRATEGY* ACE_Strategy_Acceptor< SVC_HANDLER, >::scheduling_strategy_ [protected]
 

Scheduling strategy for an {Acceptor}.

Definition at line 481 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close(), ACE_Strategy_Acceptor< SVC_HANDLER, >::resume(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::suspend().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR_ADDR ACE_Strategy_Acceptor< SVC_HANDLER, >::service_addr_ [protected]
 

Address that the {Strategy_Acceptor} uses to listen for connections.

Definition at line 497 of file Acceptor.h.

Referenced by ACE_Strategy_Acceptor< SVC_HANDLER, >::dump().

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_description_ [protected]
 

Description of the service.

Definition at line 493 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_TCHAR* ACE_Strategy_Acceptor< SVC_HANDLER, >::service_name_ [protected]
 

Name of the service.

Definition at line 490 of file Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 12:58:02 2008 for ACE by doxygen 1.3.6