3 //=============================================================================
5 * @file Thread_Adapter.h
7 * $Id: Thread_Adapter.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Carlos O'Ryan <coryan@uci.edu>
11 //=============================================================================
13 #ifndef ACE_THREAD_ADAPTER_H
14 #define ACE_THREAD_ADAPTER_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Base_Thread_Adapter.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 class ACE_Thread_Manager
;
29 class ACE_Thread_Descriptor
;
32 * @class ACE_Thread_Adapter
34 * @brief Converts a C++ function into a function that
35 * can be called from a thread creation routine
36 * (e.g., pthread_create() or _beginthreadex()) that expects an
37 * extern "C" entry point. This class also makes it possible to
38 * transparently provide hooks to register a thread with an
41 * This class is used in ACE_OS::thr_create(). In general, the
42 * thread that creates an object of this class is different from
43 * the thread that calls @c invoke() on this object. Therefore,
44 * the @c invoke() method is responsible for deleting itself.
46 class ACE_Export ACE_Thread_Adapter
: public ACE_Base_Thread_Adapter
50 ACE_Thread_Adapter (ACE_THR_FUNC user_func
,
52 ACE_THR_C_FUNC entry_point
= (ACE_THR_C_FUNC
) ACE_THREAD_ADAPTER_NAME
,
53 ACE_Thread_Manager
*thr_mgr
= 0,
54 ACE_Thread_Descriptor
*td
= 0
55 # if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
56 , ACE_SEH_EXCEPT_HANDLER selector
= 0,
57 ACE_SEH_EXCEPT_HANDLER handler
= 0
58 # endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
62 * Execute the <user_func_> with the <arg>. This function deletes
63 * @c this, thereby rendering the object useless after the call
66 virtual ACE_THR_FUNC_RETURN
invoke (void);
68 /// Accessor for the optional ACE_Thread_Manager.
69 ACE_Thread_Manager
*thr_mgr (void);
73 /// Ensure that this object must be allocated on the heap.
74 ~ACE_Thread_Adapter (void);
78 /// Called by invoke, mainly here to separate the SEH stuff because
79 /// SEH on Win32 doesn't compile with local vars with destructors.
80 virtual ACE_THR_FUNC_RETURN
invoke_i (void);
84 /// Optional thread manager.
85 ACE_Thread_Manager
*thr_mgr_
;
89 ACE_END_VERSIONED_NAMESPACE_DECL
91 # if defined (ACE_HAS_INLINED_OSCALLS)
92 # if defined (ACE_INLINE)
94 # endif /* ACE_INLINE */
95 # define ACE_INLINE inline
96 # include "ace/Thread_Adapter.inl"
97 # endif /* ACE_HAS_INLINED_OSCALLS */
99 #include /**/ "ace/post.h"
100 #endif /* ACE_THREAD_ADAPTER_H */