3 //=============================================================================
5 * @file Thread_Control.h
7 * $Id: Thread_Control.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Carlos O'Ryan <coryan@uci.edu>
11 //=============================================================================
14 #ifndef ACE_THREAD_CONTROL_H
15 #define ACE_THREAD_CONTROL_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/ACE_export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 class ACE_Thread_Manager
;
29 * @class ACE_Thread_Control
31 * @brief Used to keep track of a thread's activities within its entry
34 * A ACE_Thread_Manager uses this class to ensure that threads
35 * it spawns automatically register and unregister themselves
37 * This class can be stored in thread-specific storage using the
38 * ACE_TSS wrapper. When a thread exits the
39 * <ACE_TSS::cleanup> function deletes this object, thereby
40 * ensuring that it gets removed from its associated
43 class ACE_Export ACE_Thread_Control
46 /// Initialize the thread control object. If @a insert != 0, then
47 /// register the thread with the Thread_Manager.
48 ACE_Thread_Control (ACE_Thread_Manager
*tm
= 0,
51 /// Remove the thread from its associated <Thread_Manager> and exit
52 /// the thread if <do_thr_exit> is enabled.
53 ~ACE_Thread_Control (void);
55 /// Remove this thread from its associated ACE_Thread_Manager and exit
56 /// the thread if @a do_thr_exit is enabled.
57 ACE_THR_FUNC_RETURN
exit (ACE_THR_FUNC_RETURN status
,
60 /// Store the <Thread_Manager> and use it to register ourselves for
62 int insert (ACE_Thread_Manager
*tm
, int insert
= 0);
64 /// Returns the current <Thread_Manager>.
65 ACE_Thread_Manager
*thr_mgr (void);
67 /// Atomically set a new <Thread_Manager> and return the old
69 ACE_Thread_Manager
*thr_mgr (ACE_Thread_Manager
*);
71 /// Set the exit status (and return existing status).
72 ACE_THR_FUNC_RETURN
status (ACE_THR_FUNC_RETURN status
);
74 /// Get the current exit status.
75 ACE_THR_FUNC_RETURN
status (void);
77 /// Dump the state of an object.
78 void dump (void) const;
80 /// Declare the dynamic allocation hooks.
81 ACE_ALLOC_HOOK_DECLARE
;
84 /// Pointer to the thread manager for this block of code.
85 ACE_Thread_Manager
*tm_
;
87 /// Keeps track of the exit status for the thread.
88 ACE_THR_FUNC_RETURN status_
;
91 ACE_END_VERSIONED_NAMESPACE_DECL
93 # if defined (ACE_HAS_INLINED_OSCALLS)
94 # if defined (ACE_INLINE)
96 # endif /* ACE_INLINE */
97 # define ACE_INLINE inline
98 # include "ace/Thread_Control.inl"
99 # endif /* ACE_HAS_INLINED_OSCALLS */
101 #include /**/ "ace/post.h"
102 #endif /* ACE_THREAD_CONTROL_H */