ACE_Base_Thread_Adapter Class Reference

Base class for all the Thread_Adapters. More...

#include <Base_Thread_Adapter.h>

Inheritance diagram for ACE_Base_Thread_Adapter:

Inheritance graph
[legend]
Collaboration diagram for ACE_Base_Thread_Adapter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~ACE_Base_Thread_Adapter (void)
virtual ACE_THR_FUNC_RETURN invoke (void)=0
 Virtual method invoked by the thread entry point.

ACE_THR_C_FUNC entry_point (void)

Static Public Member Functions

void close_log_msg (void)
 Invoke the close_log_msg_hook, if it is present.

void sync_log_msg (const ACE_TCHAR *prog_name)
 Invoke the sync_log_msg_hook, if it is present.

ACE_OS_Thread_Descriptorthr_desc_log_msg (void)
 Invoke the thr_desc_log_msg_hook, if it is present.


Protected Member Functions

 ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func, void *arg, ACE_THR_C_FUNC entry_point=(ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME, ACE_OS_Thread_Descriptor *td=0)
 Constructor.

void inherit_log_msg (void)

Protected Attributes

ACE_THR_FUNC user_func_
 Thread startup function passed in by the user (C++ linkage).

void * arg_
 Argument to thread startup function.

ACE_THR_C_FUNC entry_point_
ACE_OS_Thread_Descriptorthr_desc_
ACE_OS_Log_Msg_Attributes log_msg_attributes_
 The ACE_Log_Msg attributes.


Static Private Member Functions

void set_log_msg_hooks (ACE_INIT_LOG_MSG_HOOK init_hook, ACE_INHERIT_LOG_MSG_HOOK inherit_hook, ACE_CLOSE_LOG_MSG_HOOK close_hook, ACE_SYNC_LOG_MSG_HOOK sync_hook, ACE_THR_DESC_LOG_MSG_HOOK thr_desc)
 Set the Log_Msg hooks.


Static Private Attributes

ACE_INIT_LOG_MSG_HOOK init_log_msg_hook_ = 0
 The hooks to inherit and cleanup the Log_Msg attributes.

ACE_INHERIT_LOG_MSG_HOOK inherit_log_msg_hook_ = 0
ACE_CLOSE_LOG_MSG_HOOK close_log_msg_hook_ = 0
ACE_SYNC_LOG_MSG_HOOK sync_log_msg_hook_ = 0
ACE_THR_DESC_LOG_MSG_HOOK thr_desc_log_msg_hook_ = 0

Friends

class ACE_Log_Msg
 Allow the ACE_Log_Msg class to set its hooks.


Detailed Description

Base class for all the Thread_Adapters.

Converts a C++ function into a function that can be called from a thread creation routine (e.g., pthread_create() or _beginthreadex()) that expects an extern "C" entry point. This class also makes it possible to transparently provide hooks to register a thread with an ACE_Thread_Manager. This class is used in ACE_OS::thr_create(). In general, the thread that creates an object of this class is different from the thread that calls invoke() on this object. Therefore, the invoke() method is responsible for deleting itself.

Definition at line 86 of file Base_Thread_Adapter.h.


Constructor & Destructor Documentation

ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter void   )  [virtual]
 

Definition at line 55 of file Base_Thread_Adapter.cpp.

00056 {
00057 }

ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter ACE_THR_FUNC  user_func,
void *  arg,
ACE_THR_C_FUNC  entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
ACE_OS_Thread_Descriptor td = 0
[protected]
 

Constructor.

Definition at line 25 of file Base_Thread_Adapter.cpp.

References ACE_OS_TRACE, init_log_msg_hook_, and log_msg_attributes_.

00035   : user_func_ (user_func)
00036   , arg_ (arg)
00037   , entry_point_ (entry_point)
00038   , thr_desc_ (td)
00039 {
00040   ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
00041 
00042   if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
00043     (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
00044           this->log_msg_attributes_
00045 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00046           , selector
00047           , handler
00048 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
00049           );
00050 #ifdef ACE_USES_GPROF
00051   getitimer (ITIMER_PROF, &itimer_);
00052 #endif // ACE_USES_GPROF
00053 }


Member Function Documentation

void ACE_Base_Thread_Adapter::close_log_msg void   )  [static]
 

Invoke the close_log_msg_hook, if it is present.

Definition at line 69 of file Base_Thread_Adapter.cpp.

References close_log_msg_hook_.

Referenced by ACE_OS::cleanup_tss().

00070 {
00071   if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
00072     (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
00073 }

ACE_INLINE ACE_THR_C_FUNC ACE_Base_Thread_Adapter::entry_point void   ) 
 

Accessor for the C entry point function to the OS thread creation routine.

Definition at line 35 of file Base_Thread_Adapter.inl.

References entry_point_.

Referenced by ACE_OS::thr_create().

00036 {
00037   return this->entry_point_;
00038 }

void ACE_Base_Thread_Adapter::inherit_log_msg void   )  [protected]
 

Inherit the logging features if the parent thread has an ACE_Log_Msg.

Definition at line 60 of file Base_Thread_Adapter.cpp.

References inherit_log_msg_hook_, log_msg_attributes_, and thr_desc_.

Referenced by ACE_Thread_Adapter::invoke(), and ACE_OS_Thread_Adapter::invoke().

00061 {
00062   if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
00063     (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
00064            this->thr_desc_,
00065            this->log_msg_attributes_);
00066 }

virtual ACE_THR_FUNC_RETURN ACE_Base_Thread_Adapter::invoke void   )  [pure virtual]
 

Virtual method invoked by the thread entry point.

Implemented in ACE_OS_Thread_Adapter, and ACE_Thread_Adapter.

ACE_INLINE void ACE_Base_Thread_Adapter::set_log_msg_hooks ACE_INIT_LOG_MSG_HOOK  init_hook,
ACE_INHERIT_LOG_MSG_HOOK  inherit_hook,
ACE_CLOSE_LOG_MSG_HOOK  close_hook,
ACE_SYNC_LOG_MSG_HOOK  sync_hook,
ACE_THR_DESC_LOG_MSG_HOOK  thr_desc
[static, private]
 

Set the Log_Msg hooks.

Definition at line 20 of file Base_Thread_Adapter.inl.

References ACE_CLOSE_LOG_MSG_HOOK, ACE_INHERIT_LOG_MSG_HOOK, ACE_INIT_LOG_MSG_HOOK, ACE_SYNC_LOG_MSG_HOOK, ACE_THR_DESC_LOG_MSG_HOOK, close_log_msg_hook_, inherit_log_msg_hook_, init_log_msg_hook_, sync_log_msg_hook_, and thr_desc_log_msg_hook_.

Referenced by ACE_Log_Msg::ACE_Log_Msg().

void ACE_Base_Thread_Adapter::sync_log_msg const ACE_TCHAR prog_name  )  [static]
 

Invoke the sync_log_msg_hook, if it is present.

Definition at line 76 of file Base_Thread_Adapter.cpp.

References ACE_TCHAR, and sync_log_msg_hook_.

Referenced by ACE_OS::fork().

00077 {
00078   if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
00079     (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
00080 }

ACE_OS_Thread_Descriptor * ACE_Base_Thread_Adapter::thr_desc_log_msg void   )  [static]
 

Invoke the thr_desc_log_msg_hook, if it is present.

Definition at line 83 of file Base_Thread_Adapter.cpp.

References thr_desc_log_msg_hook_.

Referenced by ACE_OS::thr_exit().

00084 {
00085   if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
00086     return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
00087   return 0;
00088 }


Friends And Related Function Documentation

friend class ACE_Log_Msg [friend]
 

Allow the ACE_Log_Msg class to set its hooks.

Definition at line 145 of file Base_Thread_Adapter.h.


Member Data Documentation

void* ACE_Base_Thread_Adapter::arg_ [protected]
 

Argument to thread startup function.

Definition at line 152 of file Base_Thread_Adapter.h.

ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0 [static, private]
 

Definition at line 21 of file Base_Thread_Adapter.cpp.

Referenced by close_log_msg(), and set_log_msg_hooks().

ACE_THR_C_FUNC ACE_Base_Thread_Adapter::entry_point_ [protected]
 

Entry point to the underlying OS thread creation call (C linkage).

Definition at line 156 of file Base_Thread_Adapter.h.

Referenced by entry_point().

ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0 [static, private]
 

Definition at line 20 of file Base_Thread_Adapter.cpp.

Referenced by inherit_log_msg(), and set_log_msg_hooks().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0 [static, private]
 

The hooks to inherit and cleanup the Log_Msg attributes.

Definition at line 19 of file Base_Thread_Adapter.cpp.

Referenced by ACE_Base_Thread_Adapter(), and set_log_msg_hooks().

ACE_OS_Log_Msg_Attributes ACE_Base_Thread_Adapter::log_msg_attributes_ [protected]
 

The ACE_Log_Msg attributes.

Definition at line 167 of file Base_Thread_Adapter.h.

Referenced by ACE_Base_Thread_Adapter(), and inherit_log_msg().

ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0 [static, private]
 

Definition at line 22 of file Base_Thread_Adapter.cpp.

Referenced by set_log_msg_hooks(), and sync_log_msg().

ACE_OS_Thread_Descriptor* ACE_Base_Thread_Adapter::thr_desc_ [protected]
 

Optional thread descriptor. Passing this pointer in will force the spawned thread to cache this location in and wait until fills in all information in thread descriptor.

Definition at line 164 of file Base_Thread_Adapter.h.

Referenced by inherit_log_msg().

ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0 [static, private]
 

Definition at line 23 of file Base_Thread_Adapter.cpp.

Referenced by set_log_msg_hooks(), and thr_desc_log_msg().

ACE_THR_FUNC ACE_Base_Thread_Adapter::user_func_ [protected]
 

Thread startup function passed in by the user (C++ linkage).

Definition at line 149 of file Base_Thread_Adapter.h.


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