diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-08-25 23:27:19 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-08-25 23:27:19 +0000 |
commit | 07641bf3bda79873da15bd4c551806f230213d43 (patch) | |
tree | 93c1a7ae2cbb60ad88b4a06ce9b0bd9a41639279 /ace/Thread_Control.cpp | |
parent | 2ecfe972ecdaf8e8f5807f22d55c060efe837712 (diff) | |
download | ATCD-07641bf3bda79873da15bd4c551806f230213d43.tar.gz |
ChangeLogTag:Fri Aug 25 16:15:50 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Thread_Control.cpp')
-rw-r--r-- | ace/Thread_Control.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/ace/Thread_Control.cpp b/ace/Thread_Control.cpp new file mode 100644 index 00000000000..13a4c063795 --- /dev/null +++ b/ace/Thread_Control.cpp @@ -0,0 +1,81 @@ +// $Id$ + +#include "ace/Thread_Control.h" +#include "ace/Thread_Manager.h" + +ACE_RCSID(ace, Thread_Control, "$Id$") + +#if !defined (ACE_HAS_INLINED_OSCALLS) +# include "ace/Thread_Control.inl" +#endif /* ACE_HAS_INLINED_OS_CALLS */ + +void +ACE_Thread_Control::dump (void) const +{ + ACE_OS_TRACE ("ACE_Thread_Control::dump"); +} + +int +ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert) +{ + ACE_OS_TRACE ("ACE_Thread_Control::insert"); + + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + this->tm_ = tm; + + if (insert) + return this->tm_->insert_thr (ACE_OS::thr_self (), t_id); + else + return 0; +} + +// Initialize the thread controller. + +ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t, + int insert) + : tm_ (t), + status_ (0) +{ + ACE_OS_TRACE ("ACE_Thread_Control::ACE_Thread_Control"); + + if (this->tm_ != 0 && insert) + { + ACE_hthread_t t_id; + ACE_OS::thr_self (t_id); + this->tm_->insert_thr (ACE_OS::thr_self (), t_id); + } +} + +// Automatically kill thread on exit. + +ACE_Thread_Control::~ACE_Thread_Control (void) +{ + ACE_OS_TRACE ("ACE_Thread_Control::~ACE_Thread_Control"); + +#if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) || defined (ACE_HAS_TSS_EMULATION) || defined (ACE_WIN32) + this->exit (this->status_, 0); +#else + this->exit (this->status_, 1); +#endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */ +} + +// Exit from thread (but clean up first). + +void * +ACE_Thread_Control::exit (void *exit_status, int do_thr_exit) +{ + ACE_OS_TRACE ("ACE_Thread_Control::exit"); + + if (this->tm_ != 0) + return this->tm_->exit (exit_status, do_thr_exit); + else + { +#if !defined (ACE_HAS_TSS_EMULATION) + // With ACE_HAS_TSS_EMULATION, we let ACE_Thread_Adapter::invoke () + // exit the thread after cleaning up TSS. + ACE_OS::thr_exit (exit_status); +#endif /* ! ACE_HAS_TSS_EMULATION */ + return 0; + } +} |