Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / Thread_Control.cpp
blob4facda2d76fda8599c52b51a272ab67c7330319c
1 #include "ace/Thread_Control.h"
2 #include "ace/Thread_Manager.h"
4 #if !defined (ACE_HAS_INLINED_OSCALLS)
5 # include "ace/Thread_Control.inl"
6 #endif /* ACE_HAS_INLINED_OSCALLS */
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 void
11 ACE_Thread_Control::dump () const
13 #if defined (ACE_HAS_DUMP)
14 ACE_OS_TRACE ("ACE_Thread_Control::dump");
15 #endif /* ACE_HAS_DUMP */
18 int
19 ACE_Thread_Control::insert (ACE_Thread_Manager *tm, bool insert)
21 ACE_OS_TRACE ("ACE_Thread_Control::insert");
23 ACE_hthread_t t_id;
24 ACE_OS::thr_self (t_id);
25 this->tm_ = tm;
27 if (insert)
28 return this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
29 else
30 return 0;
33 // Initialize the thread controller.
34 ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t,
35 int insert)
36 : tm_ (t),
37 status_ (0)
39 ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control");
41 if (this->tm_ != 0 && insert)
43 ACE_hthread_t t_id;
44 ACE_OS::thr_self (t_id);
45 this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
49 // Automatically kill thread on exit.
50 ACE_Thread_Control::~ACE_Thread_Control ()
52 ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control");
54 #if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
55 this->exit (this->status_, 0);
56 #else
57 this->exit (this->status_, 1);
58 #endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */
61 // Exit from thread (but clean up first).
62 ACE_THR_FUNC_RETURN
63 ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit)
65 ACE_OS_TRACE ("ACE_Thread_Control::exit");
67 if (this->tm_ != 0)
68 return this->tm_->exit (exit_status, do_thr_exit);
69 else
71 #if !defined (ACE_HAS_TSS_EMULATION)
72 // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke ()
73 // exit the thread after cleaning up TSS.
74 ACE_OS::thr_exit (exit_status);
75 #endif /* ! ACE_HAS_TSS_EMULATION */
76 return 0;
80 ACE_END_VERSIONED_NAMESPACE_DECL