Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Base_Thread_Adapter.cpp
blobe44e295512bd233c526b9cd99e4ea6712a41f6ef
1 #include "ace/Base_Thread_Adapter.h"
3 #if !defined (ACE_HAS_INLINED_OSCALLS)
4 # include "ace/Base_Thread_Adapter.inl"
5 #endif /* ACE_HAS_INLINED_OSCALLS */
7 #if defined (ACE_HAS_TSS_EMULATION)
8 # include "ace/OS_NS_Thread.h"
9 #endif /* ACE_HAS_TSS_EMULATION */
11 #include "ace/Service_Config.h"
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
16 ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
17 ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
18 ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
19 ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
21 ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
22 ACE_THR_FUNC user_func,
23 void *arg,
24 ACE_THR_C_FUNC entry_point,
25 ACE_OS_Thread_Descriptor *td
26 #if defined (ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS)
27 , ACE_SEH_EXCEPT_HANDLER selector
28 , ACE_SEH_EXCEPT_HANDLER handler
29 #endif /* ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */
30 , long cancel_flags
32 : user_func_ (user_func)
33 , arg_ (arg)
34 , entry_point_ (entry_point)
35 , thr_desc_ (td)
36 , ctx_ (ACE_Service_Config::current())
37 , flags_ (cancel_flags)
39 ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
41 if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
42 (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
43 this->log_msg_attributes_
44 # if defined (ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS)
45 , selector
46 , handler
47 # endif /* ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */
49 #ifdef ACE_USES_GPROF
50 getitimer (ITIMER_PROF, &itimer_);
51 #endif // ACE_USES_GPROF
54 void
55 ACE_Base_Thread_Adapter::inherit_log_msg ()
57 if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
58 (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
59 this->thr_desc_,
60 this->log_msg_attributes_);
62 // Initialize the proper configuration context for the new thread
63 // Placed here since inherit_log_msg() gets called from any of our
64 // descendants (before self-destructing)
65 ACE_Service_Config::current (this->ctx_);
68 void
69 ACE_Base_Thread_Adapter::close_log_msg ()
71 if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
72 (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
75 void
76 ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
78 if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
79 (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
82 ACE_OS_Thread_Descriptor *
83 ACE_Base_Thread_Adapter::thr_desc_log_msg ()
85 if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
86 return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
87 return 0;
90 ACE_END_VERSIONED_NAMESPACE_DECL
92 // Run the thread entry point for the <ACE_Thread_Adapter>. This must
93 // be an extern "C" to make certain compilers happy...
95 extern "C" ACE_THR_FUNC_RETURN
96 ACE_THREAD_ADAPTER_NAME (void *args)
98 ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
100 #if defined (ACE_HAS_TSS_EMULATION)
101 // As early as we can in the execution of the new thread, allocate
102 // its local TS storage. Allocate it on the stack, to save dynamic
103 // allocation/dealloction.
104 void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
105 ACE_TSS_Emulation::tss_open (ts_storage);
106 #endif /* ACE_HAS_TSS_EMULATION */
108 ACE_Base_Thread_Adapter * const thread_args =
109 static_cast<ACE_Base_Thread_Adapter *> (args);
111 #ifdef ACE_USES_GPROF
112 setitimer (ITIMER_PROF, thread_args->timerval (), 0);
113 #endif // ACE_USES_GPROF
115 // Invoke the user-supplied function with the args.
116 ACE_THR_FUNC_RETURN status = thread_args->invoke ();
118 return status;