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

Thread_Control.h

Go to the documentation of this file.
00001 
00002 //=============================================================================
00003 /**
00004  *  @file    Thread_Control.h
00005  *
00006  *  $Id: Thread_Control.h,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $
00007  *
00008  *  @author Carlos O'Ryan <coryan@uci.edu>
00009  */
00010 //=============================================================================
00011 
00012 
00013 #ifndef ACE_THREAD_CONTROL_H
00014 #define ACE_THREAD_CONTROL_H
00015 #include "ace/pre.h"
00016 
00017 #include "ace/config-all.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #if !defined (ACE_LEGACY_MODE)
00024 #  include "ace/OS.h"
00025 #endif  /* ACE_LEGACY_MODE */
00026 
00027 class ACE_Thread_Manager;
00028 
00029 /**
00030  * @class ACE_Thread_Control
00031  *
00032  * @brief Used to keep track of a thread's activities within its entry
00033  * point function.
00034  *
00035  * A ACE_Thread_Manager uses this class to ensure that threads
00036  * it spawns automatically register and unregister themselves
00037  * with it.
00038  * This class can be stored in thread-specific storage using the
00039  * ACE_TSS wrapper.  When a thread exits the
00040  * <ACE_TSS::cleanup> function deletes this object, thereby
00041  * ensuring that it gets removed from its associated
00042  * ACE_Thread_Manager.
00043  */
00044 class ACE_Export ACE_Thread_Control
00045 {
00046 public:
00047   /// Initialize the thread control object.  If <insert> != 0, then
00048   /// register the thread with the Thread_Manager.
00049   ACE_Thread_Control (ACE_Thread_Manager *tm = 0,
00050                       int insert = 0);
00051 
00052   /// Remove the thread from its associated <Thread_Manager> and exit
00053   /// the thread if <do_thr_exit> is enabled.
00054   ~ACE_Thread_Control (void);
00055 
00056   /// Remove this thread from its associated ACE_Thread_Manager and exit
00057   /// the thread if @a do_thr_exit is enabled.
00058   ACE_THR_FUNC_RETURN exit (ACE_THR_FUNC_RETURN status,
00059                             int do_thr_exit);
00060 
00061   /// Store the <Thread_Manager> and use it to register ourselves for
00062   /// correct shutdown.
00063   int insert (ACE_Thread_Manager *tm, int insert = 0);
00064 
00065   /// Returns the current <Thread_Manager>.
00066   ACE_Thread_Manager *thr_mgr (void);
00067 
00068   /// Atomically set a new <Thread_Manager> and return the old
00069   /// <Thread_Manager>.
00070   ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *);
00071 
00072   /// Set the exit status (and return existing status).
00073   ACE_THR_FUNC_RETURN status (ACE_THR_FUNC_RETURN status);
00074 
00075   /// Get the current exit status.
00076   ACE_THR_FUNC_RETURN status (void);
00077 
00078   /// Dump the state of an object.
00079   void dump (void) const;
00080 
00081   /// Declare the dynamic allocation hooks.
00082   ACE_ALLOC_HOOK_DECLARE;
00083 
00084 private:
00085   /// Pointer to the thread manager for this block of code.
00086   ACE_Thread_Manager *tm_;
00087 
00088   /// Keeps track of the exit status for the thread.
00089   ACE_THR_FUNC_RETURN status_;
00090 };
00091 
00092 # if defined (ACE_HAS_INLINED_OSCALLS)
00093 #   if defined (ACE_INLINE)
00094 #     undef ACE_INLINE
00095 #   endif /* ACE_INLINE */
00096 #   define ACE_INLINE inline
00097 #   include "ace/Thread_Control.inl"
00098 # endif /* ACE_HAS_INLINED_OSCALLS */
00099 
00100 #include "ace/post.h"
00101 #endif /* ACE_THREAD_CONTROL_H */

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