Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Thread_Control.cpp
blob51d0f4c18eb29a7862ead2462f53df17c31af754
1 // $Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $
3 // <HACK ON>
4 #include "ace/config-all.h"
5 #if defined (ACE_LEGACY_MODE)
6 // This silly include breaks a cycle when compiling in backwards
7 // compatibility mode
8 # include "ace/Thread_Exit.h"
9 #endif /* ACE_LEGACY_MODE */
10 // </HACK OFF>
12 #include "ace/Thread_Control.h"
13 #include "ace/Thread_Manager.h"
15 ACE_RCSID(ace, Thread_Control, "$Id: Thread_Control.cpp 80826 2008-03-04 14:51:23Z wotte $")
17 #if !defined (ACE_HAS_INLINED_OSCALLS)
18 # include "ace/Thread_Control.inl"
19 #endif /* ACE_HAS_INLINED_OSCALLS */
21 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
23 void
24 ACE_Thread_Control::dump (void) const
26 #if defined (ACE_HAS_DUMP)
27 ACE_OS_TRACE ("ACE_Thread_Control::dump");
28 #endif /* ACE_HAS_DUMP */
31 int
32 ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert)
34 ACE_OS_TRACE ("ACE_Thread_Control::insert");
36 ACE_hthread_t t_id;
37 ACE_OS::thr_self (t_id);
38 this->tm_ = tm;
40 if (insert)
41 return this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
42 else
43 return 0;
46 // Initialize the thread controller.
48 ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t,
49 int insert)
50 : tm_ (t),
51 status_ (0)
53 ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control");
55 if (this->tm_ != 0 && insert)
57 ACE_hthread_t t_id;
58 ACE_OS::thr_self (t_id);
59 this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
63 // Automatically kill thread on exit.
65 ACE_Thread_Control::~ACE_Thread_Control (void)
67 ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control");
69 #if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
70 this->exit (this->status_, 0);
71 #else
72 this->exit (this->status_, 1);
73 #endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */
76 // Exit from thread (but clean up first).
78 ACE_THR_FUNC_RETURN
79 ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit)
81 ACE_OS_TRACE ("ACE_Thread_Control::exit");
83 if (this->tm_ != 0)
84 return this->tm_->exit (exit_status, do_thr_exit);
85 else
87 #if !defined (ACE_HAS_TSS_EMULATION)
88 // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke ()
89 // exit the thread after cleaning up TSS.
90 ACE_OS::thr_exit (exit_status);
91 #endif /* ! ACE_HAS_TSS_EMULATION */
92 return 0;
96 ACE_END_VERSIONED_NAMESPACE_DECL