Thread_Control.cpp

Go to the documentation of this file.
00001 // Thread_Control.cpp,v 4.6 2005/10/28 23:55:10 ossama Exp
00002 
00003 // <HACK ON>
00004 #include "ace/config-all.h"
00005 #if defined (ACE_LEGACY_MODE)
00006 // This silly include breaks a cycle when compiling in backwards
00007 // compatibility mode
00008 #  include "ace/Thread_Exit.h"
00009 #endif  /* ACE_LEGACY_MODE */
00010 // </HACK OFF>
00011 
00012 #include "ace/Thread_Control.h"
00013 #include "ace/Thread_Manager.h"
00014 
00015 ACE_RCSID(ace, Thread_Control, "Thread_Control.cpp,v 4.6 2005/10/28 23:55:10 ossama Exp")
00016 
00017 #if !defined (ACE_HAS_INLINED_OSCALLS)
00018 # include "ace/Thread_Control.inl"
00019 #endif /* ACE_HAS_INLINED_OS_CALLS */
00020 
00021 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00022 
00023 void
00024 ACE_Thread_Control::dump (void) const
00025 {
00026 #if defined (ACE_HAS_DUMP)
00027   ACE_OS_TRACE ("ACE_Thread_Control::dump");
00028 #endif /* ACE_HAS_DUMP */
00029 }
00030 
00031 int
00032 ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert)
00033 {
00034   ACE_OS_TRACE ("ACE_Thread_Control::insert");
00035 
00036   ACE_hthread_t t_id;
00037   ACE_OS::thr_self (t_id);
00038   this->tm_ = tm;
00039 
00040   if (insert)
00041     return this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
00042   else
00043     return 0;
00044 }
00045 
00046 // Initialize the thread controller.
00047 
00048 ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t,
00049                                         int insert)
00050   : tm_ (t),
00051     status_ (0)
00052 {
00053   ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control");
00054 
00055   if (this->tm_ != 0 && insert)
00056     {
00057       ACE_hthread_t t_id;
00058       ACE_OS::thr_self (t_id);
00059       this->tm_->insert_thr (ACE_OS::thr_self (), t_id);
00060     }
00061 }
00062 
00063 // Automatically kill thread on exit.
00064 
00065 ACE_Thread_Control::~ACE_Thread_Control (void)
00066 {
00067   ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control");
00068 
00069 #if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32)
00070   this->exit (this->status_, 0);
00071 #else
00072   this->exit (this->status_, 1);
00073 #endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */
00074 }
00075 
00076 // Exit from thread (but clean up first).
00077 
00078 ACE_THR_FUNC_RETURN
00079 ACE_Thread_Control::exit (ACE_THR_FUNC_RETURN exit_status, int do_thr_exit)
00080 {
00081   ACE_OS_TRACE ("ACE_Thread_Control::exit");
00082 
00083   if (this->tm_ != 0)
00084     return this->tm_->exit (exit_status, do_thr_exit);
00085   else
00086     {
00087 #if !defined (ACE_HAS_TSS_EMULATION)
00088       // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke ()
00089       // exit the thread after cleaning up TSS.
00090       ACE_OS::thr_exit (exit_status);
00091 #endif /* ! ACE_HAS_TSS_EMULATION */
00092       return 0;
00093     }
00094 }
00095 
00096 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:42:06 2006 for ACE by doxygen 1.3.6