Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Thread_Adapter.h
blobf5c778b3c4d28a936f4c460db2aa0a80ac46d663
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Thread_Adapter.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
8 */
9 //=============================================================================
11 #ifndef ACE_THREAD_ADAPTER_H
12 #define ACE_THREAD_ADAPTER_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Base_Thread_Adapter.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 // Forward decl.
26 class ACE_Thread_Manager;
27 class ACE_Thread_Descriptor;
29 /**
30 * @class ACE_Thread_Adapter
32 * @brief Converts a C++ function into a function that
33 * can be called from a thread creation routine
34 * (e.g., pthread_create() or _beginthreadex()) that expects an
35 * extern "C" entry point. This class also makes it possible to
36 * transparently provide hooks to register a thread with an
37 * ACE_Thread_Manager.
39 * This class is used in ACE_OS::thr_create(). In general, the
40 * thread that creates an object of this class is different from
41 * the thread that calls @c invoke() on this object. Therefore,
42 * the @c invoke() method is responsible for deleting itself.
44 class ACE_Export ACE_Thread_Adapter : public ACE_Base_Thread_Adapter
46 public:
47 /// Constructor.
48 ACE_Thread_Adapter (ACE_THR_FUNC user_func,
49 void *arg,
50 ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ACE_THREAD_ADAPTER_NAME,
51 ACE_Thread_Manager *thr_mgr = 0,
52 ACE_Thread_Descriptor *td = 0
53 #if defined (ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS)
54 , ACE_SEH_EXCEPT_HANDLER selector = 0,
55 ACE_SEH_EXCEPT_HANDLER handler = 0
56 #endif /* ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */
57 , long cancel_flags = 0);
59 /**
60 * Execute the <user_func_> with the <arg>. This function deletes
61 * @c this, thereby rendering the object useless after the call
62 * returns.
64 virtual ACE_THR_FUNC_RETURN invoke ();
66 /// Accessor for the optional ACE_Thread_Manager.
67 ACE_Thread_Manager *thr_mgr ();
69 ACE_ALLOC_HOOK_DECLARE;
71 protected:
72 /// Ensure that this object must be allocated on the heap.
73 ~ACE_Thread_Adapter ();
75 private:
76 /// Called by invoke, mainly here to separate the SEH stuff because
77 /// SEH on Win32 doesn't compile with local vars with destructors.
78 virtual ACE_THR_FUNC_RETURN invoke_i ();
80 private:
81 /// Optional thread manager.
82 ACE_Thread_Manager *thr_mgr_;
85 ACE_END_VERSIONED_NAMESPACE_DECL
87 # if defined (ACE_HAS_INLINED_OSCALLS)
88 # if defined (ACE_INLINE)
89 # undef ACE_INLINE
90 # endif /* ACE_INLINE */
91 # define ACE_INLINE inline
92 # include "ace/Thread_Adapter.inl"
93 # endif /* ACE_HAS_INLINED_OSCALLS */
95 #include /**/ "ace/post.h"
96 #endif /* ACE_THREAD_ADAPTER_H */