SVC_HANDLER
based on multiprocessing.
More...
#include <Strategies_T.h>
Inheritance diagram for ACE_Process_Strategy< SVC_HANDLER >:
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_ |
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_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 137 of file Strategies_T.inl.
References ACE_ERROR, ACE_TEXT, ACE_TRACE, and LM_ERROR.
00141 { 00142 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::ACE_Process_Strategy"); 00143 if (this->open (n_processes, 00144 acceptor, 00145 reactor, 00146 avoid_zombies) == -1) 00147 ACE_ERROR ((LM_ERROR, 00148 ACE_TEXT ("%p\n"), 00149 ACE_TEXT ("ACE_Process_Strategy"))); 00150 }
ACE_Process_Strategy< SVC_HANDLER >::~ACE_Process_Strategy | ( | void | ) | [virtual] |
Definition at line 1337 of file Strategies_T.cpp.
References ACE_TRACE.
01338 { 01339 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy"); 01340 }
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 427 of file Strategies_T.cpp.
References ACE_Event_Handler::ACCEPT_MASK, ACE_ERROR_RETURN, ACE_TEXT, ACE_TRACE, ACE_Concurrency_Strategy< SVC_HANDLER >::activate_svc_handler(), ACE::fork(), and LM_ERROR.
00429 { 00430 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler"); 00431 00432 // If <flags_> is non-0 then we won't create zombies. 00433 switch (ACE::fork (ACE_TEXT ("child"), this->flags_)) 00434 { 00435 case -1: 00436 { 00437 ACE_Errno_Guard error (errno); 00438 svc_handler->destroy (); 00439 } 00440 ACE_ERROR_RETURN ((LM_ERROR, 00441 ACE_TEXT ("%p\n"), 00442 ACE_TEXT ("fork")), 00443 -1); 00444 /* NOTREACHED */ 00445 case 0: // In child process. 00446 00447 // Close down the SOCK_Acceptor's handle since we don't need to 00448 // keep it open. 00449 if (this->acceptor_ != 0) 00450 // Ignore the return value here... 00451 (void) this->reactor_->remove_handler (this->acceptor_, 00452 ACE_Event_Handler::ACCEPT_MASK); 00453 00454 // Call up to our ancestor in the inheritance to do the 00455 // SVC_HANDLER initialization. 00456 return this->inherited::activate_svc_handler (svc_handler, arg); 00457 /* NOTREACHED */ 00458 default: // In parent process. 00459 // We need to close down the <SVC_HANDLER> here because it's 00460 // running in the child. 00461 svc_handler->destroy (); 00462 return 0; 00463 } 00464 }
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 1343 of file Strategies_T.cpp.
References ACE_TRACE.
01344 { 01345 #if defined (ACE_HAS_DUMP) 01346 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump"); 01347 #endif /* ACE_HAS_DUMP */ 01348 }
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 412 of file Strategies_T.cpp.
References ACE_Process_Strategy< SVC_HANDLER >::acceptor_, ACE_TRACE, ACE_Concurrency_Strategy< SVC_HANDLER >::flags_, ACE_Process_Strategy< SVC_HANDLER >::n_processes_, and ACE_Process_Strategy< SVC_HANDLER >::reactor_.
00416 { 00417 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open"); 00418 this->n_processes_ = n_processes; 00419 this->acceptor_ = acceptor; 00420 this->reactor_ = reactor; 00421 this->flags_ = avoid_zombies; 00422 00423 return 0; 00424 }
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.
Referenced by ACE_Process_Strategy< SVC_HANDLER >::open().
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.
Referenced by ACE_Process_Strategy< SVC_HANDLER >::open().
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.
Referenced by ACE_Process_Strategy< SVC_HANDLER >::open().