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

ACE_Thread_Control Class Reference

Used to keep track of a thread's activities within its entry point function. More...

#include <Thread_Control.h>

Collaboration diagram for ACE_Thread_Control:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Thread_Control (ACE_Thread_Manager *tm=0, int insert=0)
 Initialize the thread control object. If <insert> != 0, then register the thread with the Thread_Manager. More...

 ~ACE_Thread_Control (void)
 Remove the thread from its associated <Thread_Manager> and exit the thread if <do_thr_exit> is enabled. More...

ACE_THR_FUNC_RETURN exit (ACE_THR_FUNC_RETURN status, int do_thr_exit)
 Remove this thread from its associated ACE_Thread_Manager and exit the thread if do_thr_exit is enabled. More...

int insert (ACE_Thread_Manager *tm, int insert=0)
 Store the <Thread_Manager> and use it to register ourselves for correct shutdown. More...

ACE_Thread_Managerthr_mgr (void)
 Returns the current <Thread_Manager>. More...

ACE_Thread_Managerthr_mgr (ACE_Thread_Manager *)
 Atomically set a new <Thread_Manager> and return the old <Thread_Manager>. More...

ACE_THR_FUNC_RETURN status (ACE_THR_FUNC_RETURN status)
 Set the exit status (and return existing status). More...

ACE_THR_FUNC_RETURN status (void)
 Get the current exit status. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Attributes

ACE_Thread_Managertm_
 Pointer to the thread manager for this block of code. More...

ACE_THR_FUNC_RETURN status_
 Keeps track of the exit status for the thread. More...


Detailed Description

Used to keep track of a thread's activities within its entry point function.

A ACE_Thread_Manager uses this class to ensure that threads it spawns automatically register and unregister themselves with it. This class can be stored in thread-specific storage using the ACE_TSS wrapper. When a thread exits the <ACE_TSS::cleanup> function deletes this object, thereby ensuring that it gets removed from its associated ACE_Thread_Manager.

Definition at line 44 of file Thread_Control.h.


Constructor & Destructor Documentation

ACE_Thread_Control::ACE_Thread_Control ACE_Thread_Manager   tm = 0,
int    insert = 0
 

Initialize the thread control object. If <insert> != 0, then register the thread with the Thread_Manager.

Definition at line 45 of file Thread_Control.cpp.

References ACE_hthread_t, ACE_OS_TRACE, insert, ACE_Thread_Manager::insert_thr, ACE_OS::thr_self, and tm_.

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 }

ACE_Thread_Control::~ACE_Thread_Control void   
 

Remove the thread from its associated <Thread_Manager> and exit the thread if <do_thr_exit> is enabled.

Definition at line 62 of file Thread_Control.cpp.

References ACE_OS_TRACE, and exit.

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 }


Member Function Documentation

void ACE_Thread_Control::dump void    const
 

Dump the state of an object.

Definition at line 23 of file Thread_Control.cpp.

References ACE_OS_TRACE.

00024 {
00025   ACE_OS_TRACE ("ACE_Thread_Control::dump");
00026 }

ACE_THR_FUNC_RETURN ACE_Thread_Control::exit ACE_THR_FUNC_RETURN    status,
int    do_thr_exit
 

Remove this thread from its associated ACE_Thread_Manager and exit the thread if do_thr_exit is enabled.

Definition at line 76 of file Thread_Control.cpp.

References ACE_OS_TRACE, ACE_Thread_Manager::exit, ACE_OS::thr_exit, and tm_.

Referenced by ~ACE_Thread_Control.

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 }

int ACE_Thread_Control::insert ACE_Thread_Manager   tm,
int    insert = 0
 

Store the <Thread_Manager> and use it to register ourselves for correct shutdown.

Definition at line 29 of file Thread_Control.cpp.

References ACE_hthread_t, ACE_OS_TRACE, ACE_Thread_Manager::insert_thr, ACE_OS::thr_self, and tm_.

Referenced by ACE_Thread_Control, and ACE_Thread_Exit::thr_mgr.

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 }

ACE_INLINE ACE_THR_FUNC_RETURN ACE_Thread_Control::status void   
 

Get the current exit status.

Definition at line 16 of file Thread_Control.inl.

References ACE_OS_TRACE, and status_.

00017 {
00018   ACE_OS_TRACE ("ACE_Thread_Control::status");
00019   return this->status_;
00020 }

ACE_INLINE ACE_THR_FUNC_RETURN ACE_Thread_Control::status ACE_THR_FUNC_RETURN    status
 

Set the exit status (and return existing status).

Definition at line 7 of file Thread_Control.inl.

References ACE_OS_TRACE, and status_.

00008 {
00009   ACE_OS_TRACE ("ACE_Thread_Control::status");
00010   return this->status_ = s;
00011 }

ACE_INLINE ACE_Thread_Manager * ACE_Thread_Control::thr_mgr ACE_Thread_Manager  
 

Atomically set a new <Thread_Manager> and return the old <Thread_Manager>.

Definition at line 35 of file Thread_Control.inl.

References ACE_OS_TRACE, and tm_.

00036 {
00037   ACE_OS_TRACE ("ACE_Thread_Control::thr_mgr");
00038   ACE_Thread_Manager *o_tm = this->tm_;
00039   this->tm_ = tm;
00040   return o_tm;
00041 }

ACE_INLINE ACE_Thread_Manager * ACE_Thread_Control::thr_mgr void   
 

Returns the current <Thread_Manager>.

Definition at line 25 of file Thread_Control.inl.

References ACE_OS_TRACE, and tm_.

00026 {
00027   ACE_OS_TRACE ("ACE_Thread_Control::thr_mgr");
00028   return this->tm_;
00029 }


Member Data Documentation

ACE_Thread_Control::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 82 of file Thread_Control.h.

ACE_THR_FUNC_RETURN ACE_Thread_Control::status_ [private]
 

Keeps track of the exit status for the thread.

Definition at line 89 of file Thread_Control.h.

Referenced by status.

ACE_Thread_Manager* ACE_Thread_Control::tm_ [private]
 

Pointer to the thread manager for this block of code.

Definition at line 86 of file Thread_Control.h.

Referenced by ACE_Thread_Control, exit, insert, and thr_mgr.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:57:28 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002