3 //=============================================================================
5 * @file Thread_Control.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
9 //=============================================================================
11 #ifndef ACE_THREAD_CONTROL_H
12 #define ACE_THREAD_CONTROL_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 class ACE_Thread_Manager
;
26 * @class ACE_Thread_Control
28 * @brief Used to keep track of a thread's activities within its entry
31 * A ACE_Thread_Manager uses this class to ensure that threads
32 * it spawns automatically register and unregister themselves
34 * This class can be stored in thread-specific storage using the
35 * ACE_TSS wrapper. When a thread exits the
36 * <ACE_TSS::cleanup> function deletes this object, thereby
37 * ensuring that it gets removed from its associated
40 class ACE_Export ACE_Thread_Control
43 /// Initialize the thread control object. If @a insert != 0, then
44 /// register the thread with the Thread_Manager.
45 ACE_Thread_Control (ACE_Thread_Manager
*tm
= 0,
48 /// Remove the thread from its associated Thread_Manager and exit
49 /// the thread if <do_thr_exit> is enabled.
50 ~ACE_Thread_Control ();
52 /// Remove this thread from its associated ACE_Thread_Manager and exit
53 /// the thread if @a do_thr_exit is enabled.
54 ACE_THR_FUNC_RETURN
exit (ACE_THR_FUNC_RETURN status
,
57 /// Store the Thread_Manager and use it to register ourselves for
59 int insert (ACE_Thread_Manager
*tm
, bool insert
= false);
61 /// Returns the current Thread_Manager.
62 ACE_Thread_Manager
*thr_mgr ();
64 /// Atomically set a new Thread_Manager and return the old
66 ACE_Thread_Manager
*thr_mgr (ACE_Thread_Manager
*);
68 /// Set the exit status (and return existing status).
69 ACE_THR_FUNC_RETURN
status (ACE_THR_FUNC_RETURN status
);
71 /// Get the current exit status.
72 ACE_THR_FUNC_RETURN
status ();
74 /// Dump the state of an object.
77 /// Declare the dynamic allocation hooks.
78 ACE_ALLOC_HOOK_DECLARE
;
81 /// Pointer to the thread manager for this block of code.
82 ACE_Thread_Manager
*tm_
;
84 /// Keeps track of the exit status for the thread.
85 ACE_THR_FUNC_RETURN status_
;
88 ACE_END_VERSIONED_NAMESPACE_DECL
90 # if defined (ACE_HAS_INLINED_OSCALLS)
91 # if defined (ACE_INLINE)
93 # endif /* ACE_INLINE */
94 # define ACE_INLINE inline
95 # include "ace/Thread_Control.inl"
96 # endif /* ACE_HAS_INLINED_OSCALLS */
98 #include /**/ "ace/post.h"
99 #endif /* ACE_THREAD_CONTROL_H */