00001 00002 //============================================================================= 00003 /** 00004 * @file OS_Thread_Adapter.h 00005 * 00006 * $Id: OS_Thread_Adapter.h,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $ 00007 * 00008 * @author Carlos O'Ryan <coryan@uci.edu> 00009 */ 00010 //============================================================================= 00011 00012 #ifndef ACE_OS_THREAD_ADAPTER_H 00013 #define ACE_OS_THREAD_ADAPTER_H 00014 #include "ace/pre.h" 00015 00016 #include "ace/Base_Thread_Adapter.h" 00017 00018 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00019 # pragma once 00020 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00021 00022 #include "ace/OS_Export.h" 00023 00024 /** 00025 * @class ACE_OS_Thread_Adapter 00026 * 00027 * @brief Converts a C++ function into a function that can be 00028 * called from a thread creation routine 00029 * (e.g., pthread_create() or _beginthreadex()) that expects an 00030 * extern "C" entry point. This class also makes it possible to 00031 * transparently provide hooks to register a thread with an 00032 * ACE_Thread_Manager. 00033 * 00034 * This class is used in ACE_OS::thr_create(). In general, the 00035 * thread that creates an object of this class is different from 00036 * the thread that calls invoke() on this object. Therefore, 00037 * the invoke() method is responsible for deleting itself. 00038 */ 00039 class ACE_OS_Export ACE_OS_Thread_Adapter : public ACE_Base_Thread_Adapter 00040 { 00041 public: 00042 /// Constructor. 00043 ACE_OS_Thread_Adapter (ACE_THR_FUNC user_func, 00044 void *arg, 00045 ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter 00046 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS) 00047 , ACE_SEH_EXCEPT_HANDLER selector = 0 00048 , ACE_SEH_EXCEPT_HANDLER handler = 0 00049 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */ 00050 ); 00051 00052 /** 00053 * Execute the @a user_func_ with the @a arg. This function deletes 00054 * @c this, thereby rendering the object useless after the call 00055 * returns. 00056 */ 00057 virtual ACE_THR_FUNC_RETURN invoke (void); 00058 00059 private: 00060 /// Ensure that this object must be allocated on the heap. 00061 ~ACE_OS_Thread_Adapter (void); 00062 00063 private: 00064 /// Friend declaration to avoid compiler warning: only defines a private 00065 /// destructor and has no friends. 00066 friend class ACE_Thread_Adapter_Has_Private_Destructor; 00067 }; 00068 00069 # if defined (ACE_HAS_INLINED_OSCALLS) 00070 # if defined (ACE_INLINE) 00071 # undef ACE_INLINE 00072 # endif /* ACE_INLINE */ 00073 # define ACE_INLINE inline 00074 # include "ace/OS_Thread_Adapter.inl" 00075 # endif /* ACE_HAS_INLINED_OSCALLS */ 00076 00077 #include "ace/post.h" 00078 #endif /* ACE_THREAD_ADAPTER_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002