00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file OS_Thread_Adapter.h 00006 * 00007 * $Id: OS_Thread_Adapter.h 74005 2006-08-14 11:30:00Z johnnyw $ 00008 * 00009 * @author Carlos O'Ryan <coryan@uci.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_OS_THREAD_ADAPTER_H 00014 #define ACE_OS_THREAD_ADAPTER_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "ace/Base_Thread_Adapter.h" 00018 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 # pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include /**/ "ace/ACE_export.h" 00024 00025 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00026 00027 /** 00028 * @class ACE_OS_Thread_Adapter 00029 * 00030 * @brief Converts a C++ function into a function that can be 00031 * called from a thread creation routine 00032 * (e.g., pthread_create() or _beginthreadex()) that expects an 00033 * extern "C" entry point. This class also makes it possible to 00034 * transparently provide hooks to register a thread with an 00035 * ACE_Thread_Manager. 00036 * 00037 * This class is used in ACE_OS::thr_create(). In general, the 00038 * thread that creates an object of this class is different from 00039 * the thread that calls invoke() on this object. Therefore, 00040 * the invoke() method is responsible for deleting itself. 00041 */ 00042 class ACE_Export ACE_OS_Thread_Adapter : public ACE_Base_Thread_Adapter 00043 { 00044 public: 00045 /// Constructor. 00046 ACE_OS_Thread_Adapter (ACE_THR_FUNC user_func, 00047 void *arg, 00048 ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME 00049 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) 00050 , ACE_SEH_EXCEPT_HANDLER selector = 0 00051 , ACE_SEH_EXCEPT_HANDLER handler = 0 00052 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ 00053 ); 00054 00055 /** 00056 * Execute the @a user_func_ with the @a arg. This function deletes 00057 * @c this, thereby rendering the object useless after the call 00058 * returns. 00059 */ 00060 virtual ACE_THR_FUNC_RETURN invoke (void); 00061 00062 protected: 00063 00064 /// Ensure that this object is allocated on the heap. 00065 ~ACE_OS_Thread_Adapter (void); 00066 00067 }; 00068 00069 ACE_END_VERSIONED_NAMESPACE_DECL 00070 00071 #include /**/ "ace/post.h" 00072 #endif /* ACE_THREAD_ADAPTER_H */