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

ACE_Process_Strategy Class Template Reference

Defines the interface for specifying a concurrency strategy for a <SVC_HANDLER> based on multiprocessing. More...

#include <Strategies_T.h>

Inheritance diagram for ACE_Process_Strategy:

Inheritance graph
[legend]
Collaboration diagram for ACE_Process_Strategy:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
base_type

Public Methods

 ACE_Process_Strategy (size_t n_processes=1, ACE_Event_Handler *acceptor=0, ACE_Reactor *=0, int avoid_zombies=0)
 Initialize the strategy. If <avoid_zombies> is non-0 then set a flag to <ACE::fork> to avoid zombies. More...

virtual int open (size_t n_processes=1, ACE_Event_Handler *acceptor=0, ACE_Reactor *=0, int avoid_zombies=0)
 Initialize the strategy. If <avoid_zombies> is non-0 then set a flag to <ACE::fork> to avoid zombies. More...

virtual ~ACE_Process_Strategy (void)
virtual int activate_svc_handler (SVC_HANDLER *svc_handler, void *arg=0)
void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Types

typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
inherited

Protected Attributes

size_t n_processes_
 Number of processes to spawn. More...

ACE_Event_Handleracceptor_
ACE_Reactorreactor_

Detailed Description

template<class SVC_HANDLER>
class ACE_Process_Strategy< SVC_HANDLER >

Defines the interface for specifying a concurrency strategy for a <SVC_HANDLER> based on multiprocessing.

This class provides a strategy that manages the creation of processes to handle requests from clients concurrently. It behaves as a "process factory", using <ACE::fork> to fork threads "on-demand" to run the service specified by a user-supplied <SVC_HANDLER> in a separate process.

Definition at line 422 of file Strategies_T.h.


Member Typedef Documentation

template<class SVC_HANDLER>
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Process_Strategy::base_type
 

Definition at line 427 of file Strategies_T.h.

template<class SVC_HANDLER>
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Process_Strategy::inherited [protected]
 

Definition at line 464 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER>
ASYS_INLINE ACE_Process_Strategy< SVC_HANDLER >::ACE_Process_Strategy size_t    n_processes = 1,
ACE_Event_Handler   acceptor = 0,
ACE_Reactor   = 0,
int    avoid_zombies = 0
 

Initialize the strategy. If <avoid_zombies> is non-0 then set a flag to <ACE::fork> to avoid zombies.

Definition at line 247 of file Strategies_T.i.

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

00251 {
00252   ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::ACE_Process_Strategy");
00253   if (this->open (n_processes,
00254                   acceptor,
00255                   reactor,
00256                   avoid_zombies) == -1)
00257     ACE_ERROR ((LM_ERROR,
00258                 ACE_LIB_TEXT ("%p\n"),
00259                 ACE_LIB_TEXT ("ACE_Process_Strategy")));
00260 }

template<class SVC_HANDLER>
ASYS_INLINE ACE_Process_Strategy< SVC_HANDLER >::~ACE_Process_Strategy void    [virtual]
 

Definition at line 263 of file Strategies_T.i.

References ACE_TRACE.

00264 {
00265   ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy");
00266 }


Member Function Documentation

template<class SVC_HANDLER>
int ACE_Process_Strategy< SVC_HANDLER >::activate_svc_handler SVC_HANDLER *    svc_handler,
void *    arg = 0
[virtual]
 

Activate the <svc_handler> with an appropriate concurrency strategy. This method activates the SVC_HANDLER by first forking and then calling the <open> method of the SVC_HANDLER in the child.

Reimplemented from ACE_Concurrency_Strategy.

Definition at line 373 of file Strategies_T.cpp.

References ACE_Event_Handler::ACCEPT_MASK, acceptor_, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE::fork, LM_ERROR, reactor_, and ACE_Reactor::remove_handler.

00375 {
00376   ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler");
00377 
00378   // If <flags_> is non-0 then we won't create zombies.
00379   switch (ACE::fork (ACE_LIB_TEXT ("child"), this->flags_))
00380     {
00381     case -1:
00382       svc_handler->destroy ();
00383       ACE_ERROR_RETURN ((LM_ERROR,
00384                          ACE_LIB_TEXT ("%p\n"),
00385                          ACE_LIB_TEXT ("fork")),
00386                         -1);
00387       /* NOTREACHED */
00388     case 0: // In child process.
00389 
00390       // Close down the SOCK_Acceptor's handle since we don't need to
00391       // keep it open.
00392       if (this->acceptor_ != 0)
00393         // Ignore the return value here...
00394         (void) this->reactor_->remove_handler (this->acceptor_,
00395                                                ACE_Event_Handler::ACCEPT_MASK);
00396 
00397       // Call up to our ancestor in the inheritance to do the
00398       // SVC_HANDLER initialization.
00399       return this->inherited::activate_svc_handler (svc_handler, arg);
00400       /* NOTREACHED */
00401     default: // In parent process.
00402       // We need to close down the <SVC_HANDLER> here because it's
00403       // running in the child.
00404       svc_handler->destroy ();
00405       return 0;
00406     }
00407 }

template<class SVC_HANDLER>
void ACE_Process_Strategy< SVC_HANDLER >::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_Concurrency_Strategy.

Definition at line 1179 of file Strategies_T.cpp.

References ACE_TRACE.

01180 {
01181   ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump");
01182 }

template<class SVC_HANDLER>
int ACE_Process_Strategy< SVC_HANDLER >::open size_t    n_processes = 1,
ACE_Event_Handler   acceptor = 0,
ACE_Reactor   = 0,
int    avoid_zombies = 0
[virtual]
 

Initialize the strategy. If <avoid_zombies> is non-0 then set a flag to <ACE::fork> to avoid zombies.

Definition at line 358 of file Strategies_T.cpp.

References acceptor_, ACE_TRACE, ACE_Concurrency_Strategy::flags_, n_processes_, and reactor_.

Referenced by ACE_Process_Strategy.

00362 {
00363   ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open");
00364   this->n_processes_ = n_processes;
00365   this->acceptor_ = acceptor;
00366   this->reactor_ = reactor;
00367   this->flags_ = avoid_zombies;
00368 
00369   return 0;
00370 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_Event_Handler* ACE_Process_Strategy::acceptor_ [protected]
 

This is the <Acceptor> in the parent is listening on. We need to make sure that we remove it from the Reactor and close it down in the child.

Definition at line 474 of file Strategies_T.h.

Referenced by activate_svc_handler, and open.

template<class SVC_HANDLER>
ACE_Process_Strategy::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Concurrency_Strategy.

Definition at line 461 of file Strategies_T.h.

template<class SVC_HANDLER>
size_t ACE_Process_Strategy::n_processes_ [protected]
 

Number of processes to spawn.

Definition at line 467 of file Strategies_T.h.

Referenced by open.

template<class SVC_HANDLER>
ACE_Reactor* ACE_Process_Strategy::reactor_ [protected]
 

This is the <Reactor> the child is using in conjunction with the <Acceptor>. We need to remove the <Acceptor> from this <Reactor> in the child.

Definition at line 481 of file Strategies_T.h.

Referenced by activate_svc_handler, and open.


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