Defines the interface for specifying a concurrency strategy for a SVC_HANDLER
based on multiprocessing.
More...
#include <Strategies_T.h>
Public Types | |
typedef ACE_Concurrency_Strategy < SVC_HANDLER > | base_type |
Public Member Functions | |
ACE_Process_Strategy (size_t n_processes=1, ACE_Event_Handler *acceptor=0, ACE_Reactor *=0, int avoid_zombies=0) | |
virtual int | open (size_t n_processes=1, ACE_Event_Handler *acceptor=0, ACE_Reactor *=0, int avoid_zombies=0) |
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. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Types | |
typedef ACE_Concurrency_Strategy < SVC_HANDLER > | inherited |
Protected Attributes | |
size_t | n_processes_ |
Number of processes to spawn. | |
ACE_Event_Handler * | acceptor_ |
ACE_Reactor * | reactor_ |
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 using a process-per-connection model. 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 426 of file Strategies_T.h.
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Process_Strategy< SVC_HANDLER >::base_type |
Definition at line 431 of file Strategies_T.h.
typedef ACE_Concurrency_Strategy<SVC_HANDLER> ACE_Process_Strategy< SVC_HANDLER >::inherited [protected] |
Definition at line 468 of file Strategies_T.h.
ACE_Process_Strategy< SVC_HANDLER >::ACE_Process_Strategy | ( | size_t | n_processes = 1 , |
|
ACE_Event_Handler * | acceptor = 0 , |
|||
ACE_Reactor * | 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 137 of file Strategies_T.inl.
ACE_Process_Strategy< SVC_HANDLER >::~ACE_Process_Strategy | ( | void | ) | [virtual] |
Definition at line 1341 of file Strategies_T.cpp.
{ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy"); }
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< SVC_HANDLER >.
Definition at line 431 of file Strategies_T.cpp.
{ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler"); // If <flags_> is non-0 then we won't create zombies. switch (ACE::fork (ACE_TEXT ("child"), this->flags_)) { case -1: { ACE_Errno_Guard error (errno); svc_handler->close (); } ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("fork")), -1); /* NOTREACHED */ case 0: // In child process. // Close down the SOCK_Acceptor's handle since we don't need to // keep it open. if (this->acceptor_ != 0) // Ignore the return value here... (void) this->reactor_->remove_handler (this->acceptor_, ACE_Event_Handler::ACCEPT_MASK); // Call up to our ancestor in the inheritance to do the // SVC_HANDLER initialization. return this->inherited::activate_svc_handler (svc_handler, arg); /* NOTREACHED */ default: // In parent process. // We need to close down the <SVC_HANDLER> here because it's // running in the child. svc_handler->close (); return 0; } }
void ACE_Process_Strategy< SVC_HANDLER >::dump | ( | void | ) | const |
Dump the state of an object.
Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >.
Definition at line 1347 of file Strategies_T.cpp.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump"); #endif /* ACE_HAS_DUMP */ }
int ACE_Process_Strategy< SVC_HANDLER >::open | ( | size_t | n_processes = 1 , |
|
ACE_Event_Handler * | acceptor = 0 , |
|||
ACE_Reactor * | 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 416 of file Strategies_T.cpp.
{ ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open"); this->n_processes_ = n_processes; this->acceptor_ = acceptor; this->reactor_ = reactor; this->flags_ = avoid_zombies; return 0; }
ACE_Event_Handler* ACE_Process_Strategy< SVC_HANDLER >::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 478 of file Strategies_T.h.
ACE_Process_Strategy< SVC_HANDLER >::ACE_ALLOC_HOOK_DECLARE |
Declare the dynamic allocation hooks.
Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >.
Definition at line 465 of file Strategies_T.h.
size_t ACE_Process_Strategy< SVC_HANDLER >::n_processes_ [protected] |
Number of processes to spawn.
Definition at line 471 of file Strategies_T.h.
ACE_Reactor* ACE_Process_Strategy< SVC_HANDLER >::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 485 of file Strategies_T.h.