00001
00002
00003 #include "ace/Base_Thread_Adapter.h"
00004
00005 ACE_RCSID (ace,
00006 Base_Thread_Adapter,
00007 "$Id: Base_Thread_Adapter.cpp 73483 2006-07-13 10:43:30Z olli $")
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 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019 ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
00020 ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
00021 ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
00022 ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
00023 ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
00024
00025 ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
00026 ACE_THR_FUNC user_func,
00027 void *arg,
00028 ACE_THR_C_FUNC entry_point,
00029 ACE_OS_Thread_Descriptor *td
00030 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00031 , ACE_SEH_EXCEPT_HANDLER selector
00032 , ACE_SEH_EXCEPT_HANDLER handler
00033 #endif
00034 )
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
00049 );
00050 #ifdef ACE_USES_GPROF
00051 getitimer (ITIMER_PROF, &itimer_);
00052 #endif // ACE_USES_GPROF
00053 }
00054
00055 ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
00056 {
00057 }
00058
00059 void
00060 ACE_Base_Thread_Adapter::inherit_log_msg (void)
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 }
00067
00068 void
00069 ACE_Base_Thread_Adapter::close_log_msg (void)
00070 {
00071 if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
00072 (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
00073 }
00074
00075 void
00076 ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
00077 {
00078 if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
00079 (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
00080 }
00081
00082 ACE_OS_Thread_Descriptor *
00083 ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
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 }
00089
00090 ACE_END_VERSIONED_NAMESPACE_DECL
00091
00092
00093
00094
00095 extern "C" ACE_THR_FUNC_RETURN
00096 ACE_THREAD_ADAPTER_NAME (void *args)
00097 {
00098 ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
00099
00100 #if defined (ACE_HAS_TSS_EMULATION)
00101
00102
00103
00104 void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
00105 ACE_TSS_Emulation::tss_open (ts_storage);
00106 #endif
00107
00108 ACE_Base_Thread_Adapter * const thread_args =
00109 static_cast<ACE_Base_Thread_Adapter *> (args);
00110
00111 #ifdef ACE_USES_GPROF
00112 setitimer (ITIMER_PROF, thread_args->timerval (), 0);
00113 #endif // ACE_USES_GPROF
00114
00115
00116 ACE_THR_FUNC_RETURN status = thread_args->invoke ();
00117
00118 return status;
00119 }
00120