Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Oneshot_Acceptor Class Template Reference

Generic factory for passively connecting clients and creating exactly one service handler (SVC_HANDLER). More...

#include <Acceptor.h>

Inheritance diagram for ACE_Oneshot_Acceptor:

Inheritance graph
[legend]
Collaboration diagram for ACE_Oneshot_Acceptor:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_PEER_ACCEPTOR_ADDR addr_type
typedef ACE_PEER_ACCEPTOR acceptor_type
typedef SVC_HANDLER handler_type
typedef ACE_TYPENAME SVC_HANDLER::stream_type stream_type

Public Methods

 ACE_Oneshot_Acceptor (void)
 Constructor. More...

 ACE_Oneshot_Acceptor (const ACE_PEER_ACCEPTOR_ADDR &local_addr, ACE_Reactor *reactor=ACE_Reactor::instance(), ACE_Concurrency_Strategy< SVC_HANDLER > *=0)
int open (const ACE_PEER_ACCEPTOR_ADDR &, ACE_Reactor *reactor=ACE_Reactor::instance(), ACE_Concurrency_Strategy< SVC_HANDLER > *=0)
virtual ~ACE_Oneshot_Acceptor (void)
 Close down the <Oneshot_Acceptor>. More...

virtual int accept (SVC_HANDLER *=0, ACE_PEER_ACCEPTOR_ADDR *remote_addr=0, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, int restart=1, int reset_new_handle=0)
 Create a <SVC_HANDLER>, accept the connection into the <SVC_HANDLER>, and activate the <SVC_HANDLER>. More...

virtual int cancel (void)
 Cancel a oneshot acceptor that was started asynchronously. More...

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

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

virtual int close (void)
 Close down the <Oneshot_Acceptor>. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
int shared_accept (SVC_HANDLER *svc_handler, ACE_PEER_ACCEPTOR_ADDR *remote_addr, ACE_Time_Value *timeout, int restart, int reset_new_handle)
 Factors out the code shared between the <accept> and <handle_input> methods. More...

virtual ACE_HANDLE get_handle (void) const
 Returns the listening acceptor's <ACE_HANDLE>. More...

virtual int handle_close (ACE_HANDLE=ACE_INVALID_HANDLE, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
 Perform termination activities when <this> is removed from the <reactor>. More...

virtual int handle_input (ACE_HANDLE)
 Accept one connection from a client and activates the SVC_HANDLER. More...

virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg)
 Called when an acceptor times out... More...

virtual int init (int argc, ACE_TCHAR *argv[])
 Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful. More...

virtual int fini (void)
 Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful. More...

virtual int info (ACE_TCHAR **, size_t) const
 Default version returns address info in <buf>. More...

virtual int suspend (void)
 Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful. More...

virtual int resume (void)
 Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful. More...


Private Methods

int register_handler (SVC_HANDLER *svc_handler, const ACE_Synch_Options &options, int restart)

Private Attributes

SVC_HANDLER * svc_handler_
 Hold the svc_handler_ across asynchrony boundaries. More...

int restart_
 Hold the restart flag across asynchrony boundaries. More...

ACE_PEER_ACCEPTOR peer_acceptor_
 Factory that establishes connections passively. More...

ACE_Concurrency_Strategy<
SVC_HANDLER > * 
concurrency_strategy_
 Concurrency strategy for an Acceptor. More...

int delete_concurrency_strategy_
 1 if Acceptor created the concurrency strategy and thus should delete it, else 0. More...


Detailed Description

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
class ACE_Oneshot_Acceptor< SVC_HANDLER, >

Generic factory for passively connecting clients and creating exactly one service handler (SVC_HANDLER).

This class works similarly to the regular <ACE_Acceptor>, with the following differences: 1. This class doesn't automagically register <this> with the <ACE_Reactor> since it expects to have its <accept> method called directly. However, it stashes the <ACE_Reactor> pointer away in case it's needed later to finish accepting a connection asynchronously. 2. The class doesn't need an <ACE_Creation_Strategy> (since the user supplies the SVC_HANDLER) or an <ACE_Accept_Strategy> (since this class only accepts one connection and then removes all traces of itself from the <ACE_Reactor> if it was registered for asynchronous accepts).

Definition at line 496 of file Acceptor.h.


Member Typedef Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR ACE_Oneshot_Acceptor::acceptor_type
 

Definition at line 502 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_PEER_ACCEPTOR_ADDR ACE_Oneshot_Acceptor::addr_type
 

Definition at line 501 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef SVC_HANDLER ACE_Oneshot_Acceptor::handler_type
 

Definition at line 503 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
typedef ACE_TYPENAME SVC_HANDLER::stream_type ACE_Oneshot_Acceptor::stream_type
 

Definition at line 504 of file Acceptor.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Oneshot_Acceptor< SVC_HANDLER, >::ACE_Oneshot_Acceptor void   
 

Constructor.

Definition at line 871 of file Acceptor.cpp.

References ACE_TRACE, and ACE_Event_Handler::reactor.

00872   : delete_concurrency_strategy_ (0)
00873 {
00874   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
00875   this->reactor (0);
00876 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Oneshot_Acceptor< SVC_HANDLER, >::ACE_Oneshot_Acceptor const ACE_PEER_ACCEPTOR_ADDR &    local_addr,
ACE_Reactor   reactor = ACE_Reactor::instance(),
ACE_Concurrency_Strategy< SVC_HANDLER > *    = 0
 

Initialize the appropriate strategies for concurrency and then open the <peer_acceptor> at the designated <local_addr>. Note that unlike the <ACE_Acceptor> and <ACE_Strategy_Acceptor>, this method does NOT register <this> acceptor with the <reactor> at this point -- it just stashes the <reactor> away in case it's needed later.

Definition at line 880 of file Acceptor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_PEER_ACCEPTOR_ADDR, ACE_TRACE, and LM_ERROR.

00883     : delete_concurrency_strategy_ (0)
00884 {
00885   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
00886   if (this->open (local_addr, reactor, cs) == -1)
00887     ACE_ERROR ((LM_ERROR,
00888                 ACE_LIB_TEXT ("%p\n"),
00889                 ACE_LIB_TEXT ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor")));
00890 }

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

Close down the <Oneshot_Acceptor>.

Definition at line 893 of file Acceptor.cpp.

References ACE_TRACE, and handle_close.

00894 {
00895   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Oneshot_Acceptor");
00896   this->handle_close ();
00897 }


Member Function Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::accept SVC_HANDLER *    = 0,
ACE_PEER_ACCEPTOR_ADDR *    remote_addr = 0,
const ACE_Synch_Options   synch_options = ACE_Synch_Options::defaults,
int    restart = 1,
int    reset_new_handle = 0
[virtual]
 

Create a <SVC_HANDLER>, accept the connection into the <SVC_HANDLER>, and activate the <SVC_HANDLER>.

Definition at line 1052 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR_ADDR, ACE_TRACE, EWOULDBLOCK, ACE_Synch_Options::USE_REACTOR, and ACE_Time_Value::zero.

01057 {
01058   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept");
01059   // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y >
01060   // 0) then this->connector_.connect() will block synchronously.  If
01061   // <use_reactor> is set then we don't want this to happen (since we
01062   // want the ACE_Reactor to do the timeout asynchronously).
01063   // Therefore, we'll force this->connector_ to use ACE_Time_Value (0,
01064   // 0) in this case...
01065 
01066   ACE_Time_Value *timeout;
01067   int use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR];
01068 
01069   if (use_reactor)
01070     timeout = (ACE_Time_Value *) &ACE_Time_Value::zero;
01071   else
01072     timeout = (ACE_Time_Value *) synch_options.time_value ();
01073 
01074   if (this->shared_accept (svc_handler, // stream
01075                            remote_addr, // remote address
01076                            timeout, // timeout
01077                            restart, // restart
01078                            reset_new_handle // reset new handler
01079                            ) == -1)
01080     {
01081       if (use_reactor && errno == EWOULDBLOCK)
01082         // We couldn't accept right away, so let's wait in the
01083         // <ACE_Reactor>.
01084         this->register_handler (svc_handler,
01085                                 synch_options,
01086                                 restart);
01087       return -1;
01088     }
01089   return 0;
01090 }

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

Return the underlying <PEER_ACCEPTOR> object.

Definition at line 1198 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR, ACE_TRACE, and peer_acceptor_.

01199 {
01200   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
01201   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01202 }

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

Bridge method for activating a <svc_handler> with the appropriate concurrency strategy. Default behavior is to activate the <SVC_HANDLER> as a "passive object." 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).

Definition at line 1002 of file Acceptor.cpp.

References ACE_TRACE.

01003 {
01004   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
01005   return this->concurrency_strategy_->activate_svc_handler
01006     (svc_handler,
01007      (void *) this);
01008 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::cancel void    [virtual]
 

Cancel a oneshot acceptor that was started asynchronously.

Definition at line 955 of file Acceptor.cpp.

References ACE_TRACE, ACE_Reactor::cancel_timer, and ACE_Event_Handler::reactor.

Referenced by handle_input.

00956 {
00957   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::cancel");
00958   return this->reactor () && this->reactor ()->cancel_timer (this);
00959 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::close void    [virtual]
 

Close down the <Oneshot_Acceptor>.

Definition at line 900 of file Acceptor.cpp.

References ACE_TRACE, and handle_close.

00901 {
00902   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close");
00903   return this->handle_close ();
00904 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
void ACE_Oneshot_Acceptor< SVC_HANDLER, >::dump void    const
 

Dump the state of an object.

Definition at line 832 of file Acceptor.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, concurrency_strategy_, delete_concurrency_strategy_, LM_DEBUG, and peer_acceptor_.

00833 {
00834   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
00835 
00836   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00837   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\nsvc_handler_ = %x"), this->svc_handler_));
00838   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("\nrestart_ = %d"), this->restart_));
00839   this->peer_acceptor_.dump ();
00840   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("delete_concurrency_strategy_ = %d"),
00841               delete_concurrency_strategy_));
00842   this->concurrency_strategy_->dump ();
00843   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00844 }

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

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Shared_Object.

Definition at line 1141 of file Acceptor.cpp.

References ACE_TRACE, and handle_close.

01142 {
01143   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
01144   return this->handle_close ();
01145 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_HANDLE ACE_Oneshot_Acceptor< SVC_HANDLER, >::get_handle void    const [protected, virtual]
 

Returns the listening acceptor's <ACE_HANDLE>.

Reimplemented from ACE_Event_Handler.

Definition at line 1191 of file Acceptor.cpp.

References ACE_TRACE, and peer_acceptor_.

01192 {
01193   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
01194   return this->peer_acceptor_.get_handle ();
01195 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_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_Event_Handler.

Definition at line 907 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, ACE_ERROR, ACE_LIB_TEXT, ACE_Reactor_Mask, ACE_TRACE, concurrency_strategy_, delete_concurrency_strategy_, ACE_Event_Handler::DONT_CALL, LM_ERROR, peer_acceptor_, ACE_Event_Handler::reactor, and ACE_Reactor::remove_handler.

Referenced by close, fini, and ~ACE_Oneshot_Acceptor.

00909 {
00910   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
00911 
00912   // Guard against multiple closes.
00913   if (this->delete_concurrency_strategy_)
00914     {
00915       delete this->concurrency_strategy_;
00916       this->delete_concurrency_strategy_ = 0;
00917       this->concurrency_strategy_ = 0;
00918 
00919       // Note that if we aren't actually registered with the
00920       // ACE_Reactor then it's ok for this call to fail...
00921 
00922       if (this->reactor ())
00923         this->reactor ()->remove_handler
00924           (this,
00925            ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
00926 
00927       if (this->peer_acceptor_.close () == -1)
00928         ACE_ERROR ((LM_ERROR,
00929                     ACE_LIB_TEXT ("close\n")));
00930     }
00931   return 0;
00932 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::handle_input ACE_HANDLE    [protected, virtual]
 

Accept one connection from a client and activates the SVC_HANDLER.

Reimplemented from ACE_Event_Handler.

Definition at line 1096 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, ACE_TRACE, cancel, ACE_Event_Handler::DONT_CALL, ACE_Event_Handler::reactor, ACE_Reactor::remove_handler, shared_accept, and ACE_Reactor::uses_event_associations.

01097 {
01098   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input");
01099   int result = 0;
01100 
01101   // Cancel any timer that might be pending.
01102   this->cancel ();
01103 
01104   // Try to find out if the implementation of the reactor that we are
01105   // using requires us to reset the event association for the newly
01106   // created handle.  This is because the newly created handle will
01107   // inherit the properties of the listen handle, including its event
01108   // associations.
01109   int reset_new_handle = this->reactor ()->uses_event_associations ();
01110 
01111   // There is a use-case whereby this object will be gone upon return
01112   // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor
01113   // during the shared_accept/activation steps. So, do whatever we need
01114   // to do with this object before calling shared_accept.
01115   if (this->reactor ())
01116     this->reactor ()->remove_handler
01117       (this,
01118        ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
01119 
01120   if (this->shared_accept (this->svc_handler_, // stream
01121                            0, // remote address
01122                            0, // timeout
01123                            this->restart_, // restart
01124                            reset_new_handle // reset new handle
01125                            ) == -1)
01126     result = -1;
01127 
01128   return result;
01129 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::handle_timeout const ACE_Time_Value   tv,
const void *    arg
[protected, virtual]
 

Called when an acceptor times out...

Reimplemented from ACE_Event_Handler.

Definition at line 936 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, ACE_TRACE, ETIME, and ACE_Event_Handler::TIMER_MASK.

00938 {
00939   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_timeout");
00940   errno = ETIME;
00941 
00942   if (this->svc_handler_->handle_timeout (tv, arg) == -1)
00943     this->svc_handler_->handle_close (this->svc_handler_->get_handle (),
00944                                       ACE_Event_Handler::TIMER_MASK);
00945 
00946   // Since we aren't necessarily registered with the Reactor, don't
00947   // bother to check the return value here...
00948   if (this->reactor ())
00949     this->reactor ()->remove_handler (this,
00950                                       ACE_Event_Handler::ACCEPT_MASK);
00951   return 0;
00952 }

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

Default version returns address info in <buf>.

Reimplemented from ACE_Shared_Object.

Definition at line 1148 of file Acceptor.cpp.

References ACE_LIB_TEXT, ACE_PEER_ACCEPTOR_ADDR, ACE_TCHAR, ACE_TRACE, peer_acceptor_, ACE_OS::sprintf, ACE_OS_String::strdup, ACE_OS_String::strlen, and ACE_OS_String::strsncpy.

01150 {
01151   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info");
01152   ACE_TCHAR buf[BUFSIZ];
01153   ACE_TCHAR addr_str[BUFSIZ];
01154   ACE_PEER_ACCEPTOR_ADDR addr;
01155 
01156   if (this->peer_acceptor_.get_local_addr (addr) == -1)
01157     return -1;
01158   else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
01159     return -1;
01160 
01161   ACE_OS::sprintf (buf,
01162                    ACE_LIB_TEXT ("%s\t %s %s"),
01163                    ACE_LIB_TEXT ("ACE_Oneshot_Acceptor"),
01164                    addr_str,
01165                    ACE_LIB_TEXT ("#oneshot acceptor factory\n"));
01166 
01167   if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
01168     return -1;
01169   else
01170     ACE_OS::strsncpy (*strp, buf, length);
01171   return ACE_static_cast (int, ACE_OS::strlen (buf));
01172 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::init int    argc,
ACE_TCHAR   argv[]
[protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Shared_Object.

Definition at line 1134 of file Acceptor.cpp.

References ACE_TCHAR, and ACE_TRACE.

01135 {
01136   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init");
01137   return -1;
01138 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::open const ACE_PEER_ACCEPTOR_ADDR &   ,
ACE_Reactor   reactor = ACE_Reactor::instance(),
ACE_Concurrency_Strategy< SVC_HANDLER > *    = 0
 

Initialize the appropriate strategies for concurrency and then open the <peer_acceptor> at the designated <local_addr>. Note that unlike the <ACE_Acceptor> and <ACE_Strategy_Acceptor>, this method does NOT register <this> acceptor with the <reactor> at this point -- it just stashes the <reactor> away in case it's needed later.

Definition at line 848 of file Acceptor.cpp.

References ACE_NEW_RETURN, ACE_PEER_ACCEPTOR_ADDR, ACE_TRACE, and ACE_Strategy_Acceptor::open.

00851 {
00852   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00853   this->reactor (reactor);
00854 
00855   // Initialize the concurrency strategy.
00856 
00857   if (con_s == 0)
00858     {
00859       ACE_NEW_RETURN (con_s,
00860                       ACE_Concurrency_Strategy<SVC_HANDLER>,
00861                       -1);
00862       this->delete_concurrency_strategy_ = 1;
00863     }
00864   this->concurrency_strategy_ = con_s;
00865 
00866   // Reuse the addr, even if it is already in use...!
00867   return this->peer_acceptor_.open (local_addr, 1);
00868 }

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

Return the underlying <PEER_ACCEPTOR> object.

Definition at line 1205 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR, ACE_TRACE, and peer_acceptor_.

01206 {
01207   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
01208   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01209 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::register_handler SVC_HANDLER *    svc_handler,
const ACE_Synch_Options   options,
int    restart
[private]
 

Insert ourselves into the <ACE_Reactor> so that we can continue accepting this connection asynchronously. This method should NOT be called by developers directly.

Definition at line 963 of file Acceptor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, and ACE_TRACE.

00966 {
00967   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::register_handler");
00968   // Can't do this if we don't have a Reactor.
00969   if (this->reactor () == 0)
00970     {
00971       errno = EINVAL;
00972       return -1;
00973     }
00974   else
00975     {
00976       this->svc_handler_ = svc_handler;
00977       this->restart_ = restart;
00978       ACE_Time_Value *tv = (ACE_Time_Value *) synch_options.time_value ();
00979 
00980       if (tv != 0
00981           && this->reactor ()->schedule_timer (this,
00982                                                synch_options.arg (),
00983                                                *tv) == 0)
00984         return -1;
00985       else
00986         return this->reactor ()->register_handler
00987           (this,
00988            ACE_Event_Handler::ACCEPT_MASK);
00989     }
00990 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::resume void    [protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Service_Object.

Definition at line 1182 of file Acceptor.cpp.

References ACE_TRACE, ACE_Event_Handler::reactor, and ACE_Reactor::resume_handler.

01183 {
01184   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
01185   return this->reactor () && this->reactor ()->resume_handler (this);
01186 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::shared_accept SVC_HANDLER *    svc_handler,
ACE_PEER_ACCEPTOR_ADDR *    remote_addr,
ACE_Time_Value   timeout,
int    restart,
int    reset_new_handle
[protected]
 

Factors out the code shared between the <accept> and <handle_input> methods.

Definition at line 1015 of file Acceptor.cpp.

References ACE_PEER_ACCEPTOR_ADDR, ACE_TRACE, ETIME, and EWOULDBLOCK.

Referenced by handle_input.

01020 {
01021   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::shared_accept");
01022   if (svc_handler == 0)
01023     return -1;
01024 
01025   // Accept connection into the Svc_Handler.
01026   else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
01027                                         remote_addr, // remote address
01028                                         timeout, // timeout
01029                                         restart, // restart
01030                                         reset_new_handle // reset new handle
01031                                         ) == -1)
01032     {
01033       // Check whether we just timed out or whether we failed...
01034       if (!(errno == EWOULDBLOCK || errno == ETIME))
01035         // Close down handler to avoid memory leaks.
01036         svc_handler->close (0);
01037       return -1;
01038     }
01039   // Activate the <svc_handler> using the designated concurrency
01040   // strategy (note that this method becomes responsible for handling
01041   // errors and freeing up the memory if things go awry...)
01042   else
01043     return this->activate_svc_handler (svc_handler);
01044 }

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, >::suspend void    [protected, virtual]
 

Default version does no work and returns -1. Must be overloaded by application developer to do anything meaningful.

Reimplemented from ACE_Service_Object.

Definition at line 1175 of file Acceptor.cpp.

References ACE_TRACE, ACE_Event_Handler::reactor, and ACE_Reactor::suspend_handler.

01176 {
01177   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
01178   return this->reactor () && this->reactor ()->suspend_handler (this);
01179 }


Member Data Documentation

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Oneshot_Acceptor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 561 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_Concurrency_Strategy<SVC_HANDLER>* ACE_Oneshot_Acceptor::concurrency_strategy_ [private]
 

Concurrency strategy for an Acceptor.

Definition at line 640 of file Acceptor.h.

Referenced by dump, and handle_close.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor::delete_concurrency_strategy_ [private]
 

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

Definition at line 644 of file Acceptor.h.

Referenced by dump, and handle_close.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
ACE_PEER_ACCEPTOR ACE_Oneshot_Acceptor::peer_acceptor_ [private]
 

Factory that establishes connections passively.

Definition at line 637 of file Acceptor.h.

Referenced by acceptor, dump, get_handle, handle_close, info, and operator ACE_PEER_ACCEPTOR &.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor::restart_ [private]
 

Hold the restart flag across asynchrony boundaries.

Definition at line 634 of file Acceptor.h.

template<class SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >
SVC_HANDLER* ACE_Oneshot_Acceptor::svc_handler_ [private]
 

Hold the svc_handler_ across asynchrony boundaries.

Definition at line 631 of file Acceptor.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:51:23 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002