00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file Cleanup_Func_Registry.h 00006 * 00007 * Cleanup_Func_Registry.h,v 1.9 2006/03/10 07:19:04 jtc Exp 00008 * 00009 * @author Ossama Othman <ossama@dre.vanderbilt.edu> 00010 */ 00011 // =================================================================== 00012 00013 #ifndef TAO_CLEANUP_FUNC_REGISTRY_H 00014 #define TAO_CLEANUP_FUNC_REGISTRY_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/TAO_Export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/Versioned_Namespace.h" 00025 00026 #include "ace/Array_Base.h" 00027 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 /** 00032 * @class TAO_Cleanup_Func_Registry 00033 * 00034 * @brief 00035 * This is a helper class that is designed to perform cleanup on 00036 * thread-specific objects registered in the ORB Core TSS resources by 00037 * invoking the corresponding cleanup function on each object. Hence, 00038 * there is a tight coupling between this class and the TAO ORB Core. 00039 */ 00040 class TAO_Cleanup_Func_Registry 00041 { 00042 friend class TAO_ORB_Core; 00043 00044 public: 00045 00046 /// Constructor. 00047 TAO_Cleanup_Func_Registry (void); 00048 00049 /// Return the number of registered cleanup functions. 00050 size_t size (void) const; 00051 00052 protected: 00053 00054 /// Register a cleanup function. The number of slot the cleanup 00055 /// function is placed is in will match the one reserved for the 00056 /// corresponding thread specific object in the ORB Core TSS 00057 /// resources. The slot_id is returned via the second reference 00058 /// argument. This method returns 0 on failure, and -1 on failure. 00059 int register_cleanup_function (ACE_CLEANUP_FUNC func, 00060 size_t &slot_id); 00061 00062 /// Invoke the corresponding cleanup function on each 00063 /// thread-specific object. 00064 void cleanup (ACE_Array_Base<void *> &ts_objects); 00065 00066 private: 00067 00068 /// Prevent copying through the copy constructor and the assignment 00069 /// operator. 00070 TAO_Cleanup_Func_Registry (const TAO_Cleanup_Func_Registry &); 00071 void operator= (const TAO_Cleanup_Func_Registry &); 00072 00073 private: 00074 00075 /// Array of registered cleanup functions. The number of 00076 /// registered cleanup functions should be the same as the number 00077 /// of registered thread-specific objects in the ORB Core TSS 00078 /// resources. 00079 ACE_Array_Base<ACE_CLEANUP_FUNC> cleanup_funcs_; 00080 00081 }; 00082 00083 TAO_END_VERSIONED_NAMESPACE_DECL 00084 00085 #if defined (__ACE_INLINE__) 00086 # include "tao/Cleanup_Func_Registry.inl" 00087 #endif /* __ACE_INLINE__ */ 00088 00089 00090 #include /**/ "ace/post.h" 00091 00092 #endif /* TAO_CLEANUP_FUNC_REGISTRY_H */