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.
|
Definition at line 431 of file Strategies_T.h. |
|
Definition at line 468 of file Strategies_T.h. |
|
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, LM_ERROR, and ACE_Process_Strategy< SVC_HANDLER >::open().
|
|
Definition at line 1338 of file Strategies_T.cpp. References ACE_TRACE.
01339 { 01340 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::~ACE_Process_Strategy"); 01341 } |
|
Activate the svc_handler with an appropriate concurrency strategy. This method activates the SVC_HANDLER by first forking and then calling the Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >. Definition at line 428 of file Strategies_T.cpp. References ACE_ERROR_RETURN, ACE_TEXT, ACE_TRACE, ACE::fork(), LM_ERROR, and ACE_Reactor::remove_handler().
00430 { 00431 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler"); 00432 00433 // If <flags_> is non-0 then we won't create zombies. 00434 switch (ACE::fork (ACE_TEXT ("child"), this->flags_)) 00435 { 00436 case -1: 00437 { 00438 ACE_Errno_Guard error (errno); 00439 svc_handler->destroy (); 00440 } 00441 ACE_ERROR_RETURN ((LM_ERROR, 00442 ACE_TEXT ("%p\n"), 00443 ACE_TEXT ("fork")), 00444 -1); 00445 /* NOTREACHED */ 00446 case 0: // In child process. 00447 00448 // Close down the SOCK_Acceptor's handle since we don't need to 00449 // keep it open. 00450 if (this->acceptor_ != 0) 00451 // Ignore the return value here... 00452 (void) this->reactor_->remove_handler (this->acceptor_, 00453 ACE_Event_Handler::ACCEPT_MASK); 00454 00455 // Call up to our ancestor in the inheritance to do the 00456 // SVC_HANDLER initialization. 00457 return this->inherited::activate_svc_handler (svc_handler, arg); 00458 /* NOTREACHED */ 00459 default: // In parent process. 00460 // We need to close down the <SVC_HANDLER> here because it's 00461 // running in the child. 00462 svc_handler->destroy (); 00463 return 0; 00464 } 00465 } |
|
Dump the state of an object.
Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >. Definition at line 1344 of file Strategies_T.cpp. References ACE_TRACE.
01345 { 01346 #if defined (ACE_HAS_DUMP) 01347 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::dump"); 01348 #endif /* ACE_HAS_DUMP */ 01349 } |
|
Initialize the strategy. If avoid_zombies is non-0 then set a flag to ACE::fork() to avoid zombies. Definition at line 413 of file Strategies_T.cpp. References ACE_TRACE, and ACE_Process_Strategy< SVC_HANDLER >::n_processes_. Referenced by ACE_Process_Strategy< SVC_HANDLER >::ACE_Process_Strategy().
00417 { 00418 ACE_TRACE ("ACE_Process_Strategy<SVC_HANDLER>::open"); 00419 this->n_processes_ = n_processes; 00420 this->acceptor_ = acceptor; 00421 this->reactor_ = reactor; 00422 this->flags_ = avoid_zombies; 00423 00424 return 0; 00425 } |
|
This is the Definition at line 478 of file Strategies_T.h. |
|
Declare the dynamic allocation hooks.
Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >. Definition at line 465 of file Strategies_T.h. |
|
Number of processes to spawn.
Definition at line 471 of file Strategies_T.h. Referenced by ACE_Process_Strategy< SVC_HANDLER >::open(). |
|
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. |