ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 > 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< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >:
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 SVC_HANDLER::stream_type stream_type

Public Member Functions

 ACE_Oneshot_Acceptor (void)
 Constructor.
 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}.
virtual int accept (SVC_HANDLER *=0, ACE_PEER_ACCEPTOR_ADDR *remote_addr=0, const ACE_Synch_Options &synch_options=ACE_Synch_Options::defaults, bool restart=true, bool reset_new_handle=false)
virtual int cancel (void)
 Cancel a oneshot acceptor that was started asynchronously.
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 int close (void)
 Close down the {Oneshot_Acceptor}.
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Member Functions

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, bool restart, bool reset_new_handle)
virtual ACE_HANDLE get_handle (void) const
 Returns the listening acceptor's {ACE_HANDLE}.
virtual int handle_close (ACE_HANDLE=ACE_INVALID_HANDLE, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
virtual int handle_input (ACE_HANDLE)
virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg)
 Called when an acceptor times out...
virtual int init (int argc, ACE_TCHAR *argv[])
virtual int fini (void)
virtual int info (ACE_TCHAR **, size_t) const
 Default version returns address info in {buf}.
virtual int suspend (void)
virtual int resume (void)

Private Member Functions

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

Private Attributes

SVC_HANDLER * svc_handler_
 Hold the svc_handler_ across asynchrony boundaries.
bool restart_
 Hold the restart flag across asynchrony boundaries.
ACE_PEER_ACCEPTOR peer_acceptor_
 Factory that establishes connections passively.
ACE_Concurrency_Strategy
< SVC_HANDLER > * 
concurrency_strategy_
 Concurrency strategy for an Acceptor.
bool delete_concurrency_strategy_

Detailed Description

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

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 523 of file Acceptor.h.


Member Typedef Documentation

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

Definition at line 529 of file Acceptor.h.

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

Definition at line 528 of file Acceptor.h.

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

Definition at line 530 of file Acceptor.h.

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

Definition at line 531 of file Acceptor.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::ACE_Oneshot_Acceptor ( void   )  [inline]

Constructor.

Definition at line 905 of file Acceptor.cpp.

00906   : delete_concurrency_strategy_ (false)
00907 {
00908   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
00909   this->reactor (0);
00910 }

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

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 914 of file Acceptor.cpp.

00917     : delete_concurrency_strategy_ (false)
00918 {
00919   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor");
00920   if (this->open (local_addr, reactor, cs) == -1)
00921     ACE_ERROR ((LM_ERROR,
00922                 ACE_TEXT ("%p\n"),
00923                 ACE_TEXT ("ACE_Oneshot_Acceptor::ACE_Oneshot_Acceptor")));
00924 }

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

Close down the {Oneshot_Acceptor}.

Definition at line 927 of file Acceptor.cpp.

00928 {
00929   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::~ACE_Oneshot_Acceptor");
00930   this->handle_close ();
00931 }


Member Function Documentation

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::accept ( SVC_HANDLER *  svc_handler = 0,
ACE_PEER_ACCEPTOR_ADDR *  remote_addr = 0,
const ACE_Synch_Options synch_options = ACE_Synch_Options::defaults,
bool  restart = true,
bool  reset_new_handle = false 
) [inline, virtual]

Create a {SVC_HANDLER}, accept the connection into the {SVC_HANDLER}, and activate the {SVC_HANDLER}.

Definition at line 1085 of file Acceptor.cpp.

01090 {
01091   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept");
01092   // Note that if timeout == ACE_Time_Value (x, y) where (x > 0 || y >
01093   // 0) then this->connector_.connect() will block synchronously.  If
01094   // <use_reactor> is set then we don't want this to happen (since we
01095   // want the ACE_Reactor to do the timeout asynchronously).
01096   // Therefore, we'll force this->connector_ to use ACE_Time_Value (0,
01097   // 0) in this case...
01098 
01099   ACE_Time_Value *timeout;
01100   int use_reactor = synch_options[ACE_Synch_Options::USE_REACTOR];
01101 
01102   if (use_reactor)
01103     timeout = (ACE_Time_Value *) &ACE_Time_Value::zero;
01104   else
01105     timeout = (ACE_Time_Value *) synch_options.time_value ();
01106 
01107   if (this->shared_accept (svc_handler, // stream
01108                            remote_addr, // remote address
01109                            timeout, // timeout
01110                            restart, // restart
01111                            reset_new_handle // reset new handler
01112                            ) == -1)
01113     {
01114       if (use_reactor && errno == EWOULDBLOCK)
01115         // We couldn't accept right away, so let's wait in the
01116         // <ACE_Reactor>.
01117         this->register_handler (svc_handler,
01118                                 synch_options,
01119                                 restart);
01120       return -1;
01121     }
01122   return 0;
01123 }

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

Return the underlying {PEER_ACCEPTOR} object.

Definition at line 1231 of file Acceptor.cpp.

01232 {
01233   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::acceptor");
01234   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01235 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::activate_svc_handler ( SVC_HANDLER *  svc_handler  )  [inline, 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 1035 of file Acceptor.cpp.

01036 {
01037   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::activate_svc_handler");
01038   return this->concurrency_strategy_->activate_svc_handler
01039     (svc_handler,
01040      (void *) this);
01041 }

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

Cancel a oneshot acceptor that was started asynchronously.

Definition at line 988 of file Acceptor.cpp.

00989 {
00990   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::cancel");
00991   return this->reactor () && this->reactor ()->cancel_timer (this);
00992 }

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

Close down the {Oneshot_Acceptor}.

Definition at line 934 of file Acceptor.cpp.

00935 {
00936   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::close");
00937   return this->handle_close ();
00938 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
void ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::dump ( void   )  const [inline]

Dump the state of an object.

Definition at line 864 of file Acceptor.cpp.

00865 {
00866 #if defined (ACE_HAS_DUMP)
00867   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::dump");
00868 
00869   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00870   ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("\nsvc_handler_ = %x"), this->svc_handler_));
00871   ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("\nrestart_ = %d"), this->restart_));
00872   this->peer_acceptor_.dump ();
00873   ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("delete_concurrency_strategy_ = %d"),
00874               delete_concurrency_strategy_));
00875   this->concurrency_strategy_->dump ();
00876   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00877 #endif /* ACE_HAS_DUMP */
00878 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::fini ( void   )  [inline, 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 1174 of file Acceptor.cpp.

01175 {
01176   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::fini");
01177   return this->handle_close ();
01178 }

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

Returns the listening acceptor's {ACE_HANDLE}.

Reimplemented from ACE_Event_Handler.

Definition at line 1224 of file Acceptor.cpp.

01225 {
01226   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::get_handle");
01227   return this->peer_acceptor_.get_handle ();
01228 }

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

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

Reimplemented from ACE_Event_Handler.

Definition at line 941 of file Acceptor.cpp.

00943 {
00944   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close");
00945 
00946   // Guard against multiple closes.
00947   if (this->delete_concurrency_strategy_)
00948     {
00949       delete this->concurrency_strategy_;
00950       this->delete_concurrency_strategy_ = false;
00951       this->concurrency_strategy_ = 0;
00952     }
00953   // Note that if we aren't actually registered with the
00954   // ACE_Reactor then it's ok for this call to fail...
00955 
00956   if (this->reactor ())
00957     this->reactor ()->remove_handler
00958       (this,
00959        ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
00960 
00961   if (this->peer_acceptor_.close () == -1)
00962     ACE_ERROR ((LM_ERROR,
00963                 ACE_TEXT ("close\n")));
00964   return 0;
00965 }

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

Accept one connection from a client and activates the SVC_HANDLER.

Reimplemented from ACE_Event_Handler.

Definition at line 1129 of file Acceptor.cpp.

01130 {
01131   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input");
01132   int result = 0;
01133 
01134   // Cancel any timer that might be pending.
01135   this->cancel ();
01136 
01137   // Try to find out if the implementation of the reactor that we are
01138   // using requires us to reset the event association for the newly
01139   // created handle.  This is because the newly created handle will
01140   // inherit the properties of the listen handle, including its event
01141   // associations.
01142   bool const reset_new_handle = this->reactor ()->uses_event_associations ();
01143 
01144   // There is a use-case whereby this object will be gone upon return
01145   // from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor
01146   // during the shared_accept/activation steps. So, do whatever we need
01147   // to do with this object before calling shared_accept.
01148   if (this->reactor ())
01149     this->reactor ()->remove_handler
01150       (this,
01151        ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
01152 
01153   if (this->shared_accept (this->svc_handler_, // stream
01154                            0, // remote address
01155                            0, // timeout
01156                            this->restart_, // restart
01157                            reset_new_handle // reset new handle
01158                            ) == -1)
01159     result = -1;
01160 
01161   return result;
01162 }

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

Called when an acceptor times out...

Reimplemented from ACE_Event_Handler.

Definition at line 969 of file Acceptor.cpp.

00971 {
00972   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_timeout");
00973   errno = ETIME;
00974 
00975   if (this->svc_handler_->handle_timeout (tv, arg) == -1)
00976     this->svc_handler_->handle_close (this->svc_handler_->get_handle (),
00977                                       ACE_Event_Handler::TIMER_MASK);
00978 
00979   // Since we aren't necessarily registered with the Reactor, don't
00980   // bother to check the return value here...
00981   if (this->reactor ())
00982     this->reactor ()->remove_handler (this,
00983                                       ACE_Event_Handler::ACCEPT_MASK);
00984   return 0;
00985 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::info ( ACE_TCHAR **  strp,
size_t  length 
) const [inline, protected, virtual]

Default version returns address info in {buf}.

Reimplemented from ACE_Shared_Object.

Definition at line 1181 of file Acceptor.cpp.

01183 {
01184   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::info");
01185   ACE_TCHAR buf[BUFSIZ];
01186   ACE_TCHAR addr_str[BUFSIZ];
01187   ACE_PEER_ACCEPTOR_ADDR addr;
01188 
01189   if (this->peer_acceptor_.get_local_addr (addr) == -1)
01190     return -1;
01191   else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
01192     return -1;
01193 
01194   ACE_OS::sprintf (buf,
01195                    ACE_TEXT ("%s\t %s %s"),
01196                    ACE_TEXT ("ACE_Oneshot_Acceptor"),
01197                    addr_str,
01198                    ACE_TEXT ("#oneshot acceptor factory\n"));
01199 
01200   if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
01201     return -1;
01202   else
01203     ACE_OS::strsncpy (*strp, buf, length);
01204   return static_cast<int> (ACE_OS::strlen (buf));
01205 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::init ( int  argc,
ACE_TCHAR argv[] 
) [inline, 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 1167 of file Acceptor.cpp.

01168 {
01169   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::init");
01170   return -1;
01171 }

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

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 882 of file Acceptor.cpp.

00885 {
00886   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open");
00887   this->reactor (reactor);
00888 
00889   // Initialize the concurrency strategy.
00890 
00891   if (con_s == 0)
00892     {
00893       ACE_NEW_RETURN (con_s,
00894                       ACE_Concurrency_Strategy<SVC_HANDLER>,
00895                       -1);
00896       this->delete_concurrency_strategy_ = true;
00897     }
00898   this->concurrency_strategy_ = con_s;
00899 
00900   // Reuse the addr, even if it is already in use...!
00901   return this->peer_acceptor_.open (local_addr, 1);
00902 }

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

Return the underlying {PEER_ACCEPTOR} object.

Definition at line 1238 of file Acceptor.cpp.

01239 {
01240   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::operator ACE_PEER_ACCEPTOR &");
01241   return (ACE_PEER_ACCEPTOR &) this->peer_acceptor_;
01242 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::register_handler ( SVC_HANDLER *  svc_handler,
const ACE_Synch_Options options,
bool  restart 
) [inline, 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 996 of file Acceptor.cpp.

00999 {
01000   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::register_handler");
01001   // Can't do this if we don't have a Reactor.
01002   if (this->reactor () == 0)
01003     {
01004       errno = EINVAL;
01005       return -1;
01006     }
01007   else
01008     {
01009       this->svc_handler_ = svc_handler;
01010       this->restart_ = restart;
01011       ACE_Time_Value *tv = (ACE_Time_Value *) synch_options.time_value ();
01012 
01013       if (tv != 0
01014           && this->reactor ()->schedule_timer (this,
01015                                                synch_options.arg (),
01016                                                *tv) == 0)
01017         return -1;
01018       else
01019         return this->reactor ()->register_handler
01020           (this,
01021            ACE_Event_Handler::ACCEPT_MASK);
01022     }
01023 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::resume ( void   )  [inline, 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 1215 of file Acceptor.cpp.

01216 {
01217   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::resume");
01218   return this->reactor () && this->reactor ()->resume_handler (this);
01219 }

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

Factors out the code shared between the {accept} and {handle_input} methods.

Definition at line 1048 of file Acceptor.cpp.

01053 {
01054   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::shared_accept");
01055   if (svc_handler == 0)
01056     return -1;
01057 
01058   // Accept connection into the Svc_Handler.
01059   else if (this->peer_acceptor_.accept (svc_handler->peer (), // stream
01060                                         remote_addr, // remote address
01061                                         timeout, // timeout
01062                                         restart, // restart
01063                                         reset_new_handle // reset new handle
01064                                         ) == -1)
01065     {
01066       // Check whether we just timed out or whether we failed...
01067       if (!(errno == EWOULDBLOCK || errno == ETIME))
01068         // Close down handler to avoid memory leaks.
01069         svc_handler->close (CLOSE_DURING_NEW_CONNECTION);
01070       return -1;
01071     }
01072   // Activate the <svc_handler> using the designated concurrency
01073   // strategy (note that this method becomes responsible for handling
01074   // errors and freeing up the memory if things go awry...)
01075   else
01076     return this->activate_svc_handler (svc_handler);
01077 }

template<class SVC_HANDLER , ACE_PEER_ACCEPTOR_1 >
int ACE_Oneshot_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_1 >::suspend ( void   )  [inline, 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 1208 of file Acceptor.cpp.

01209 {
01210   ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::suspend");
01211   return this->reactor () && this->reactor ()->suspend_handler (this);
01212 }


Member Data Documentation

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

Declare the dynamic allocation hooks.

Definition at line 588 of file Acceptor.h.

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

Concurrency strategy for an Acceptor.

Definition at line 667 of file Acceptor.h.

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

true if Acceptor created the concurrency strategy and thus should delete it, else false.

Definition at line 671 of file Acceptor.h.

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

Factory that establishes connections passively.

Definition at line 664 of file Acceptor.h.

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

Hold the restart flag across asynchrony boundaries.

Definition at line 661 of file Acceptor.h.

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

Hold the svc_handler_ across asynchrony boundaries.

Definition at line 658 of file Acceptor.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Fri Nov 6 23:25:08 2009 for ACE by  doxygen 1.6.1