Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Thread_Control.cpp

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

Generated on Mon Jun 16 11:21:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002