Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Thread_Control.h
blobd22a21166ffefc71d42b0e9669340c056ee1c981
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Thread_Control.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
8 */
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)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 class ACE_Thread_Manager;
25 /**
26 * @class ACE_Thread_Control
28 * @brief Used to keep track of a thread's activities within its entry
29 * point function.
31 * A ACE_Thread_Manager uses this class to ensure that threads
32 * it spawns automatically register and unregister themselves
33 * with it.
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
38 * ACE_Thread_Manager.
40 class ACE_Export ACE_Thread_Control
42 public:
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,
46 int insert = 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,
55 int do_thr_exit);
57 /// Store the Thread_Manager and use it to register ourselves for
58 /// correct shutdown.
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
65 /// Thread_Manager.
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.
75 void dump () const;
77 /// Declare the dynamic allocation hooks.
78 ACE_ALLOC_HOOK_DECLARE;
80 private:
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)
92 # undef 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 */