ACE  6.4.2
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR > Class Template Reference

Generic factory for passively connecting clients and creating exactly one service handler of the type SVC_HANDLER specified in the template. More...

#include <Acceptor.h>

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

Public Types

typedef PEER_ACCEPTOR::PEER_ADDR addr_type
 
typedef PEER_ACCEPTOR acceptor_type
 
typedef SVC_HANDLER handler_type
 
typedef SVC_HANDLER::stream_type stream_type
 
- Public Types inherited from ACE_Event_Handler
enum  {
  LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, READ_MASK = (1 << 0),
  WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4),
  TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8),
  ALL_EVENTS_MASK, RWE_MASK, DONT_CALL = (1 << 9)
}
 
enum  { ACE_EVENT_HANDLER_NOT_RESUMED = -1, ACE_REACTOR_RESUMES_HANDLER = 0, ACE_APPLICATION_RESUMES_HANDLER }
 
typedef long Reference_Count
 Reference count type. More...
 

Public Member Functions

 ACE_Oneshot_Acceptor (void)
 Constructor. More...
 
 ACE_Oneshot_Acceptor (const typename PEER_ACCEPTOR::PEER_ADDR &local_addr, ACE_Reactor *reactor=ACE_Reactor::instance(), ACE_Concurrency_Strategy< SVC_HANDLER > *=0)
 
int open (const typename PEER_ACCEPTOR::PEER_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, typename PEER_ACCEPTOR::PEER_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. More...
 
virtual operator PEER_ACCEPTOR & () const
 Return the underlying {PEER_ACCEPTOR} object. More...
 
virtual 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 Member Functions inherited from ACE_Service_Object
 ACE_Service_Object (ACE_Reactor *=0)
 Constructor. More...
 
virtual ~ACE_Service_Object (void)
 Destructor. More...
 
- Public Member Functions inherited from ACE_Event_Handler
virtual ~ACE_Event_Handler (void)
 Destructor is virtual to enable proper cleanup. More...
 
virtual void set_handle (ACE_HANDLE)
 Set the I/O handle. More...
 
virtual int priority (void) const
 
virtual void priority (int priority)
 Set the priority of the Event_Handler. More...
 
virtual int handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Called when an exceptional events occur (e.g., SIGURG). More...
 
virtual int handle_exit (ACE_Process *)
 Called when a process exits. More...
 
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 
virtual int resume_handler (void)
 
virtual int handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual int handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual void reactor (ACE_Reactor *reactor)
 Set the event demultiplexors. More...
 
virtual ACE_Reactorreactor (void) const
 Get the event demultiplexors. More...
 
virtual ACE_Reactor_Timer_Interfacereactor_timer_interface (void) const
 Get only the reactor's timer related interface. More...
 
virtual Reference_Count add_reference (void)
 Increment reference count on the handler. More...
 
virtual Reference_Count remove_reference (void)
 Decrement reference count on the handler. More...
 
Reference_Counting_Policyreference_counting_policy (void)
 Current Reference_Counting_Policy. More...
 
- Public Member Functions inherited from ACE_Shared_Object
 ACE_Shared_Object (void)
 Constructor. More...
 
virtual ~ACE_Shared_Object (void)
 Destructor. More...
 

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 
- Public Attributes inherited from ACE_Service_Object
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 

Protected Member Functions

virtual int activate_svc_handler (SVC_HANDLER *svc_handler)
 
int shared_accept (SVC_HANDLER *svc_handler, typename PEER_ACCEPTOR::PEER_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}. More...
 
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... More...
 
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}. More...
 
virtual int suspend (void)
 
virtual int resume (void)
 
- Protected Member Functions inherited from ACE_Event_Handler
 ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY)
 Force ACE_Event_Handler to be an abstract base class. More...
 

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. More...
 
bool restart_
 Hold the restart flag across asynchrony boundaries. More...
 
PEER_ACCEPTOR peer_acceptor_
 Factory that establishes connections passively. More...
 
ACE_Concurrency_Strategy< SVC_HANDLER > * concurrency_strategy_
 Concurrency strategy for an Acceptor. More...
 
bool delete_concurrency_strategy_
 

Additional Inherited Members

- Static Public Member Functions inherited from ACE_Event_Handler
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler)
 
static int register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED)
 
static int remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr)
 Performs the inverse of the register_stdin_handler() method. More...
 
- Protected Types inherited from ACE_Event_Handler
typedef ACE_Atomic_Op< ACE_SYNCH_MUTEX, Reference_CountAtomic_Reference_Count
 Typedef for implementation of reference counting. More...
 
- Protected Attributes inherited from ACE_Event_Handler
Atomic_Reference_Count reference_count_
 Reference count. More...
 

Detailed Description

template<typename SVC_HANDLER, typename PEER_ACCEPTOR>
class ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >

Generic factory for passively connecting clients and creating exactly one service handler of the type SVC_HANDLER specified in the template.

This class works similarly to the regular ACE_Acceptor, but with the following differences:

  1. ACE_Oneshot_Acceptor doesn't automatically register itself with the ACE_Reactor; the caller is expected to call the accept() method directly. Since a later call to accept() may require a reactor, the constructor and open() methods both accept an ACE_Reactor pointer which is saved in case it's needed in accept().
  2. ACE_Oneshot_Acceptor doesn't need an ACE_Creation_Strategy (because the user supplies the SVC_HANDLER) or an ACE_Accept_Strategy (because this class only accepts one connection and then removes all traces of itself from the ACE_Reactor if it was registered for asynchronous accepts).

The usage model for ACE_Oneshot_Acceptor is:

Member Typedef Documentation

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
typedef PEER_ACCEPTOR ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::acceptor_type
template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
typedef PEER_ACCEPTOR::PEER_ADDR ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::addr_type
template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
typedef SVC_HANDLER ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::handler_type
template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
typedef SVC_HANDLER::stream_type ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::stream_type

Constructor & Destructor Documentation

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::ACE_Oneshot_Acceptor ( void  )

Constructor.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::ACE_Oneshot_Acceptor ( const typename PEER_ACCEPTOR::PEER_ADDR &  local_addr,
ACE_Reactor reactor = ACE_Reactor::instance (),
ACE_Concurrency_Strategy< SVC_HANDLER > *  cs = 0 
)

Initialize the appropriate strategies for concurrency and then open the acceptor at the designated local_addr. Note that unlike ACE_Acceptor and ACE_Strategy_Acceptor, this method does NOT register this acceptor with the reactor at this point – the reactor parameter is saved in case it's needed later.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::~ACE_Oneshot_Acceptor ( void  )
virtual

Close down the {Oneshot_Acceptor}.

Member Function Documentation

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::accept ( SVC_HANDLER *  svc_handler = 0,
typename PEER_ACCEPTOR::PEER_ADDR *  remote_addr = 0,
const ACE_Synch_Options synch_options = ACE_Synch_Options::defaults,
bool  restart = true,
bool  reset_new_handle = false 
)
virtual

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

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
PEER_ACCEPTOR & ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::acceptor ( void  ) const
virtual

Return the underlying {PEER_ACCEPTOR} object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::activate_svc_handler ( SVC_HANDLER *  svc_handler)
protectedvirtual

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).

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::cancel ( void  )
virtual

Cancel a oneshot acceptor that was started asynchronously.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::close ( void  )
virtual

Close down the {Oneshot_Acceptor}.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
PEER_ACCEPTOR void ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::dump ( void  ) const

Dump the state of an object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::fini ( void  )
protectedvirtual

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

Reimplemented from ACE_Shared_Object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_HANDLE ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::get_handle ( void  ) const
protectedvirtual

Returns the listening acceptor's {ACE_HANDLE}.

Reimplemented from ACE_Event_Handler.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::handle_close ( ACE_HANDLE  = ACE_INVALID_HANDLE,
ACE_Reactor_Mask  = ACE_Event_Handler::ALL_EVENTS_MASK 
)
protectedvirtual

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

Reimplemented from ACE_Event_Handler.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::handle_input ( ACE_HANDLE  )
protectedvirtual

Accept one connection from a client and activates the SVC_HANDLER.

Reimplemented from ACE_Event_Handler.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::handle_timeout ( const ACE_Time_Value tv,
const void *  arg 
)
protectedvirtual

Called when an acceptor times out...

Reimplemented from ACE_Event_Handler.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::info ( ACE_TCHAR **  strp,
size_t  length 
) const
protectedvirtual

Default version returns address info in {buf}.

Reimplemented from ACE_Shared_Object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::init ( int  argc,
ACE_TCHAR argv[] 
)
protectedvirtual

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

Reimplemented from ACE_Shared_Object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::open ( const typename PEER_ACCEPTOR::PEER_ADDR &  local_addr,
ACE_Reactor reactor = ACE_Reactor::instance (),
ACE_Concurrency_Strategy< SVC_HANDLER > *  con_s = 0 
)

Initialize the appropriate strategies for concurrency and then open the acceptor at the designated local_addr. Note that unlike ACE_Acceptor and ACE_Strategy_Acceptor, this method does NOT register this acceptor with the reactor at this point – the reactor parameter is saved in case it's needed later.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::operator PEER_ACCEPTOR & ( ) const
virtual

Return the underlying {PEER_ACCEPTOR} object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::register_handler ( SVC_HANDLER *  svc_handler,
const ACE_Synch_Options options,
bool  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.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::resume ( void  )
protectedvirtual

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

Reimplemented from ACE_Service_Object.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::shared_accept ( SVC_HANDLER *  svc_handler,
typename PEER_ACCEPTOR::PEER_ADDR *  remote_addr,
ACE_Time_Value timeout,
bool  restart,
bool  reset_new_handle 
)
protected

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

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
int ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::suspend ( void  )
protectedvirtual

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

Reimplemented from ACE_Service_Object.

Member Data Documentation

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
ACE_Concurrency_Strategy<SVC_HANDLER>* ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::concurrency_strategy_
private

Concurrency strategy for an Acceptor.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
bool ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::delete_concurrency_strategy_
private

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

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
PEER_ACCEPTOR ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::peer_acceptor_
private

Factory that establishes connections passively.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
bool ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::restart_
private

Hold the restart flag across asynchrony boundaries.

template<typename SVC_HANDLER , typename PEER_ACCEPTOR >
SVC_HANDLER* ACE_Oneshot_Acceptor< SVC_HANDLER, PEER_ACCEPTOR >::svc_handler_
private

Hold the svc_handler_ across asynchrony boundaries.


The documentation for this class was generated from the following files: