Go to the documentation of this file.00001
00002
00003 #include "ace/Base_Thread_Adapter.h"
00004
00005 ACE_RCSID (ace,
00006 Base_Thread_Adapter,
00007 "$Id: Base_Thread_Adapter.cpp 84340 2009-02-05 22:28:08Z stallions $")
00008
00009 #if !defined (ACE_HAS_INLINED_OSCALLS)
00010 # include "ace/Base_Thread_Adapter.inl"
00011 #endif
00012
00013 #if defined (ACE_HAS_TSS_EMULATION)
00014 # include "ace/OS_NS_Thread.h"
00015 #endif
00016
00017 #include "ace/Service_Config.h"
00018
00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021 ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
00022 ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
00023 ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
00024 ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
00025 ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
00026
00027 ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
00028 ACE_THR_FUNC user_func,
00029 void *arg,
00030 ACE_THR_C_FUNC entry_point,
00031 ACE_OS_Thread_Descriptor *td
00032 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00033 , ACE_SEH_EXCEPT_HANDLER selector
00034 , ACE_SEH_EXCEPT_HANDLER handler
00035 #endif
00036 )
00037 : user_func_ (user_func)
00038 , arg_ (arg)
00039 , entry_point_ (entry_point)
00040 , thr_desc_ (td)
00041 , ctx_ (ACE_Service_Config::current())
00042 {
00043 ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
00044
00045 if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
00046 (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
00047 this->log_msg_attributes_
00048 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00049 , selector
00050 , handler
00051 # endif
00052 );
00053 #ifdef ACE_USES_GPROF
00054 getitimer (ITIMER_PROF, &itimer_);
00055 #endif // ACE_USES_GPROF
00056 }
00057
00058 ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
00059 {
00060 }
00061
00062 void
00063 ACE_Base_Thread_Adapter::inherit_log_msg (void)
00064 {
00065 if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
00066 (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
00067 this->thr_desc_,
00068 this->log_msg_attributes_);
00069
00070
00071
00072
00073 ACE_Service_Config::current (this->ctx_);
00074 }
00075
00076 void
00077 ACE_Base_Thread_Adapter::close_log_msg (void)
00078 {
00079 if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
00080 (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
00081 }
00082
00083 void
00084 ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
00085 {
00086 if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
00087 (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
00088 }
00089
00090 ACE_OS_Thread_Descriptor *
00091 ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
00092 {
00093 if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
00094 return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
00095 return 0;
00096 }
00097
00098 ACE_END_VERSIONED_NAMESPACE_DECL
00099
00100
00101
00102
00103 extern "C" ACE_THR_FUNC_RETURN
00104 ACE_THREAD_ADAPTER_NAME (void *args)
00105 {
00106 ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
00107
00108 #if defined (ACE_HAS_TSS_EMULATION)
00109
00110
00111
00112 void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
00113 ACE_TSS_Emulation::tss_open (ts_storage);
00114 #endif
00115
00116 ACE_Base_Thread_Adapter * const thread_args =
00117 static_cast<ACE_Base_Thread_Adapter *> (args);
00118
00119 #ifdef ACE_USES_GPROF
00120 setitimer (ITIMER_PROF, thread_args->timerval (), 0);
00121 #endif // ACE_USES_GPROF
00122
00123
00124 ACE_THR_FUNC_RETURN status = thread_args->invoke ();
00125
00126 return status;
00127 }
00128