ACE_Thread_Strategy< SVC_HANDLER > Class Template Reference

Defines the interface for specifying a concurrency strategy for a based on multithreading. More...

#include <Strategies_T.h>

Inheritance diagram for ACE_Thread_Strategy< SVC_HANDLER >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Thread_Strategy< SVC_HANDLER >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Concurrency_Strategy<
SVC_HANDLER > 
base_type

Public Member Functions

 ACE_Thread_Strategy (int flags=0)
 "Do-nothing constructor"

 ACE_Thread_Strategy (ACE_Thread_Manager *tm, long thr_flags, int n_threads=1, int flags=0)
 Initialize the strategy.

virtual int open (ACE_Thread_Manager *tm, long thr_flags, int n_threads=1, int flags=0)
 Initialize the strategy.

virtual ~ACE_Thread_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

ACE_Thread_Managerthr_mgr_
 Thread manager for this class (must be provided).

long thr_flags_
 Flags to pass into the <SVC_HANDLER::activate> method.

int n_threads_
 Number of threads to spawn.


Detailed Description

template<class SVC_HANDLER>
class ACE_Thread_Strategy< SVC_HANDLER >

Defines the interface for specifying a concurrency strategy for a based on multithreading.

This class provides a strategy that manages the creation of threads to handle requests from clients concurrently via a thread-per-connection model. It behaves as a "thread factory", spawning threads "on-demand" to run the service specified by a user-supplied .

Definition at line 359 of file Strategies_T.h.


Member Typedef Documentation

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

Definition at line 364 of file Strategies_T.h.

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

Definition at line 401 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER>
ACE_INLINE ACE_Thread_Strategy< SVC_HANDLER >::ACE_Thread_Strategy int  flags = 0  ) 
 

"Do-nothing constructor"

Definition at line 114 of file Strategies_T.inl.

References ACE_TRACE.

00115   : ACE_Concurrency_Strategy<SVC_HANDLER> (flags),
00116     thr_mgr_ (0),
00117     thr_flags_ (0),
00118     n_threads_ (1)
00119 {
00120   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::ACE_Thread_Strategy");
00121 }

template<class SVC_HANDLER>
ACE_INLINE ACE_Thread_Strategy< SVC_HANDLER >::ACE_Thread_Strategy ACE_Thread_Manager tm,
long  thr_flags,
int  n_threads = 1,
int  flags = 0
 

Initialize the strategy.

Definition at line 97 of file Strategies_T.inl.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and ACE_Thread_Strategy< SVC_HANDLER >::open().

00101 {
00102   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::ACE_Thread_Strategy");
00103 
00104   if (this->open (thr_mgr,
00105                   thr_flags,
00106                   n_threads,
00107                   flags) == -1)
00108     ACE_ERROR ((LM_ERROR,
00109                 ACE_LIB_TEXT ("%p\n"),
00110                 ACE_LIB_TEXT ("ACE_Thread_Strategy<SVC_HANDLER>::ACE_Thread_Strategy")));
00111 }

template<class SVC_HANDLER>
ACE_Thread_Strategy< SVC_HANDLER >::~ACE_Thread_Strategy void   )  [virtual]
 

Definition at line 1272 of file Strategies_T.cpp.

References ACE_TRACE.

01273 {
01274   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::~ACE_Thread_Strategy");
01275 }


Member Function Documentation

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

Activate the with an appropriate concurrency strategy. This method activates the SVC_HANDLER by first calling its method and then calling its method to turn it into an active object.

Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >.

Definition at line 283 of file Strategies_T.cpp.

References ACE_TRACE.

00285 {
00286   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::activate_svc_handler");
00287   // Call up to our parent to do the SVC_HANDLER initialization.
00288   if (this->inherited::activate_svc_handler (svc_handler,
00289                                              arg) == -1)
00290     return -1;
00291   else
00292     // Turn the <svc_handler> into an active object (if it isn't
00293     // already one as a result of the first activation...)
00294     return svc_handler->activate (this->thr_flags_,
00295                                   this->n_threads_);
00296 }

template<class SVC_HANDLER>
void ACE_Thread_Strategy< SVC_HANDLER >::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >.

Definition at line 1278 of file Strategies_T.cpp.

References ACE_TRACE.

01279 {
01280 #if defined (ACE_HAS_DUMP)
01281   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::dump");
01282 #endif /* ACE_HAS_DUMP */
01283 }

template<class SVC_HANDLER>
int ACE_Thread_Strategy< SVC_HANDLER >::open ACE_Thread_Manager tm,
long  thr_flags,
int  n_threads = 1,
int  flags = 0
[virtual]
 

Initialize the strategy.

Definition at line 262 of file Strategies_T.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE_Thread_Strategy< SVC_HANDLER >::n_threads_, and ACE_Thread_Strategy< SVC_HANDLER >::thr_flags_.

Referenced by ACE_Thread_Strategy< SVC_HANDLER >::ACE_Thread_Strategy().

00266 {
00267   ACE_TRACE ("ACE_Thread_Strategy<SVC_HANDLER>::open");
00268   this->thr_mgr_ = thr_mgr;
00269   this->n_threads_ = n_threads;
00270   this->thr_flags_ = thr_flags;
00271   this->flags_ = flags;
00272 
00273   // Must have a thread manager!
00274   if (this->thr_mgr_ == 0)
00275     ACE_ERROR_RETURN ((LM_ERROR,
00276                        ACE_LIB_TEXT ("error: must have a non-NULL thread manager\n")),
00277                       -1);
00278   else
00279     return 0;
00280 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_Thread_Strategy< SVC_HANDLER >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Concurrency_Strategy< SVC_HANDLER >.

Definition at line 398 of file Strategies_T.h.

template<class SVC_HANDLER>
int ACE_Thread_Strategy< SVC_HANDLER >::n_threads_ [protected]
 

Number of threads to spawn.

Definition at line 410 of file Strategies_T.h.

Referenced by ACE_Thread_Strategy< SVC_HANDLER >::open().

template<class SVC_HANDLER>
long ACE_Thread_Strategy< SVC_HANDLER >::thr_flags_ [protected]
 

Flags to pass into the <SVC_HANDLER::activate> method.

Definition at line 407 of file Strategies_T.h.

Referenced by ACE_Thread_Strategy< SVC_HANDLER >::open().

template<class SVC_HANDLER>
ACE_Thread_Manager* ACE_Thread_Strategy< SVC_HANDLER >::thr_mgr_ [protected]
 

Thread manager for this class (must be provided).

Definition at line 404 of file Strategies_T.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:31:05 2006 for ACE by doxygen 1.3.6