Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Base_Thread_Adapter.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Base_Thread_Adapter.cpp,v 1.1.1.2.2.1 2003/03/13 19:44:20 chad Exp $
00003 
00004 #include "ace/Base_Thread_Adapter.h"
00005 #include "ace/OS.h"
00006 
00007 ACE_RCSID(ace, Base_Thread_Adapter, "$Id: Base_Thread_Adapter.cpp,v 1.1.1.2.2.1 2003/03/13 19:44:20 chad Exp $")
00008 
00009 #if !defined (ACE_HAS_INLINED_OSCALLS)
00010 # include "ace/Base_Thread_Adapter.inl"
00011 #endif /* ACE_HAS_INLINED_OS_CALLS */
00012 
00013 ACE_INIT_LOG_MSG_HOOK     ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
00014 ACE_INHERIT_LOG_MSG_HOOK  ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
00015 ACE_CLOSE_LOG_MSG_HOOK    ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
00016 ACE_SYNC_LOG_MSG_HOOK     ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
00017 ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
00018 
00019 ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
00020      ACE_THR_FUNC user_func,
00021      void *arg,
00022      ACE_THR_C_FUNC entry_point,
00023      ACE_OS_Thread_Descriptor *td
00024 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00025      , ACE_SEH_EXCEPT_HANDLER selector
00026      , ACE_SEH_EXCEPT_HANDLER handler
00027 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
00028    )
00029   : user_func_ (user_func)
00030   , arg_ (arg)
00031   , entry_point_ (entry_point)
00032   , thr_desc_ (td)
00033 {
00034   ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
00035 
00036   if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
00037     (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
00038           this->log_msg_attributes_
00039 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00040           , selector
00041           , handler
00042 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
00043           );
00044 }
00045 
00046 ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
00047 {
00048 }
00049 
00050 void
00051 ACE_Base_Thread_Adapter::inherit_log_msg (void)
00052 {
00053   if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
00054     (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
00055            this->thr_desc_,
00056            this->log_msg_attributes_);
00057 }
00058 
00059 void
00060 ACE_Base_Thread_Adapter::close_log_msg (void)
00061 {
00062   if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
00063     (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
00064 }
00065 
00066 void
00067 ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
00068 {
00069   if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
00070     (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
00071 }
00072 
00073 ACE_OS_Thread_Descriptor *
00074 ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
00075 {
00076   if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
00077     return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
00078   return 0;
00079 }
00080 
00081 // Run the thread entry point for the <ACE_Thread_Adapter>.  This must
00082 // be an extern "C" to make certain compilers happy...
00083 
00084 #if defined (ACE_PSOS)
00085 extern "C" void 
00086 ace_thread_adapter (unsigned long args)
00087 {
00088   ACE_OS_TRACE ("ace_thread_adapter");
00089 
00090 #if defined (ACE_HAS_TSS_EMULATION)
00091   // As early as we can in the execution of the new thread, allocate
00092   // its local TS storage.  Allocate it on the stack, to save dynamic
00093   // allocation/dealloction.
00094   void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
00095   ACE_TSS_Emulation::tss_open (ts_storage);
00096 #endif /* ACE_HAS_TSS_EMULATION */
00097 
00098   ACE_Base_Thread_Adapter *thread_args =
00099     ACE_static_cast(ACE_Base_Thread_Adapter *, args);
00100 
00101   // Invoke the user-supplied function with the args.
00102   thread_args->invoke ();
00103 }
00104 #else /* ! defined (ACE_PSOS) */
00105 extern "C" ACE_THR_FUNC_RETURN
00106 ace_thread_adapter (void *args)
00107 {
00108   ACE_OS_TRACE ("ace_thread_adapter");
00109 
00110 #if defined (ACE_HAS_TSS_EMULATION)
00111   // As early as we can in the execution of the new thread, allocate
00112   // its local TS storage.  Allocate it on the stack, to save dynamic
00113   // allocation/dealloction.
00114   void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
00115   ACE_TSS_Emulation::tss_open (ts_storage);
00116 #endif /* ACE_HAS_TSS_EMULATION */
00117 
00118   ACE_Base_Thread_Adapter *thread_args =
00119     ACE_static_cast (ACE_Base_Thread_Adapter *, args);
00120 
00121   // Invoke the user-supplied function with the args.
00122   ACE_THR_FUNC_RETURN status = thread_args->invoke ();
00123 
00124   return status;
00125 }
00126 #endif /* ACE_PSOS */

Generated on Mon Jun 16 11:19:12 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002