#include <OS_Thread_Adapter.h>
Inheritance diagram for ACE_OS_Thread_Adapter:


Public Member Functions | |
| ACE_OS_Thread_Adapter (ACE_THR_FUNC user_func, void *arg, ACE_THR_C_FUNC entry_point=(ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME) | |
| Constructor. | |
| virtual ACE_THR_FUNC_RETURN | invoke (void) |
Protected Member Functions | |
| ~ACE_OS_Thread_Adapter (void) | |
| Ensure that this object is allocated on the heap. | |
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 42 of file OS_Thread_Adapter.h.
|
||||||||||||||||
|
Constructor.
Definition at line 16 of file OS_Thread_Adapter.cpp.
00025 : ACE_Base_Thread_Adapter (user_func, arg, entry_point 00026 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) 00027 , 0 00028 , selector 00029 , handler 00030 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ 00031 ) 00032 { 00033 } |
|
|
Ensure that this object is allocated on the heap.
Definition at line 35 of file OS_Thread_Adapter.cpp.
00036 {
00037 }
|
|
|
Execute the user_func_ with the arg. This function deletes Implements ACE_Base_Thread_Adapter. Definition at line 40 of file OS_Thread_Adapter.cpp. References ACE_hthread_t, ACE_SEH_EXCEPT, ACE_SEH_FINALLY, ACE_SEH_TRY, ACE_Thread_Manager::at_exit(), ACE_Task_Base::cleanup(), ACE_OS::cleanup_tss(), ACE_Base_Thread_Adapter::inherit_log_msg(), ACE_Thread_Hook::start(), ACE_OS::thr_getprio(), ACE_Task_Base::thr_mgr(), ACE_OS::thr_self(), ACE_OS::thr_setprio(), and ACE_OS_Object_Manager::thread_hook().
00041 {
00042 // Inherit the logging features if the parent thread has an
00043 // ACE_Log_Msg instance in thread-specific storage.
00044 this->inherit_log_msg ();
00045
00046 // Extract the arguments.
00047 ACE_THR_FUNC_INTERNAL func =
00048 reinterpret_cast<ACE_THR_FUNC_INTERNAL> (this->user_func_);
00049 void *arg = this->arg_;
00050
00051 // Delete ourselves since we don't need <this> anymore. Make sure
00052 // not to access <this> anywhere below this point.
00053 delete this;
00054
00055 #if defined (ACE_NEEDS_LWP_PRIO_SET)
00056 // On SunOS, the LWP priority needs to be set in order to get
00057 // preemption when running in the RT class. This is the ACE way to
00058 // do that . . .
00059 ACE_hthread_t thr_handle;
00060 ACE_OS::thr_self (thr_handle);
00061 int prio;
00062
00063 // thr_getprio () on the current thread should never fail.
00064 ACE_OS::thr_getprio (thr_handle, prio);
00065
00066 // ACE_OS::thr_setprio () has the special logic to set the LWP priority,
00067 // if running in the RT class.
00068 ACE_OS::thr_setprio (prio);
00069
00070 #endif /* ACE_NEEDS_LWP_PRIO_SET */
00071
00072 ACE_THR_FUNC_RETURN status = 0;
00073
00074 ACE_SEH_TRY
00075 {
00076 ACE_SEH_TRY
00077 {
00078 ACE_Thread_Hook *hook =
00079 ACE_OS_Object_Manager::thread_hook ();
00080
00081 if (hook)
00082 // Invoke the start hook to give the user a chance to
00083 // perform some initialization processing before the
00084 // <func> is invoked.
00085 status = hook->start (reinterpret_cast<ACE_THR_FUNC> (func),
00086 arg);
00087 else
00088 {
00089 // Call thread entry point.
00090 status = (*func) (arg);
00091 }
00092 }
00093
00094 #if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
00095 ACE_SEH_EXCEPT (ACE_OS_Object_Manager::seh_except_selector ()(
00096 (void *) GetExceptionInformation ()))
00097 {
00098 ACE_OS_Object_Manager::seh_except_handler ()(0);
00099 }
00100 #endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
00101 }
00102
00103 ACE_SEH_FINALLY
00104 {
00105 // If we changed this to 1, change the respective if in
00106 // Task::svc_run to 0.
00107 #if 0
00108 // Call the <Task->close> hook.
00109 if (func == reinterpret_cast<ACE_THR_FUNC_INTERNAL> (ACE_Task_Base::svc_run))
00110 {
00111 ACE_Task_Base *task_ptr = (ACE_Task_Base *) arg;
00112 ACE_Thread_Manager *thr_mgr_ptr = task_ptr->thr_mgr ();
00113
00114 // This calls the Task->close () hook.
00115 task_ptr->cleanup (task_ptr, 0);
00116
00117 // This prevents a second invocation of the cleanup code
00118 // (called later by <ACE_Thread_Manager::exit>.
00119 thr_mgr_ptr->at_exit (task_ptr, 0, 0);
00120 }
00121 #endif /* 0 */
00122
00123 #if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
00124 // Call TSS destructors.
00125 ACE_OS::cleanup_tss (0 /* not main thread */);
00126
00127 # if defined (ACE_WIN32)
00128 // Exit the thread. Allow CWinThread-destructor to be invoked
00129 // from AfxEndThread. _endthreadex will be called from
00130 // AfxEndThread so don't exit the thread now if we are running
00131 // an MFC thread.
00132 # if defined (ACE_HAS_MFC) && (ACE_HAS_MFC != 0)
00133 // Not spawned by ACE_Thread_Manager, use the old buggy
00134 // version. You should seriously consider using
00135 // ACE_Thread_Manager to spawn threads. The following code
00136 // is know to cause some problem.
00137 CWinThread *pThread = ::AfxGetThread ();
00138
00139 if (!pThread || pThread->m_nThreadID != ACE_OS::thr_self ())
00140 ACE_ENDTHREADEX (status);
00141 else
00142 ::AfxEndThread (status);
00143 # else
00144 ACE_ENDTHREADEX (status);
00145 # endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
00146 # endif /* ACE_WIN32 */
00147 #endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
00148 }
00149
00150 return status;
00151 }
|
1.3.6