00001 // -*- C++ -*- 00002 00003 // =================================================================== 00004 /** 00005 * @file Cleanup_Func_Registry.h 00006 * 00007 * $Id: Cleanup_Func_Registry.h 78190 2007-04-25 08:52:32Z johnnyw $ 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, size_t &slot_id); 00060 00061 /// Invoke the corresponding cleanup function on each 00062 /// thread-specific object. 00063 void cleanup (ACE_Array_Base<void *> &ts_objects); 00064 00065 private: 00066 00067 /// Prevent copying through the copy constructor and the assignment 00068 /// operator. 00069 TAO_Cleanup_Func_Registry (const TAO_Cleanup_Func_Registry &); 00070 void operator= (const TAO_Cleanup_Func_Registry &); 00071 00072 private: 00073 00074 /// Array of registered cleanup functions. The number of 00075 /// registered cleanup functions should be the same as the number 00076 /// of registered thread-specific objects in the ORB Core TSS 00077 /// resources. 00078 ACE_Array_Base<ACE_CLEANUP_FUNC> cleanup_funcs_; 00079 00080 }; 00081 00082 TAO_END_VERSIONED_NAMESPACE_DECL 00083 00084 #if defined (__ACE_INLINE__) 00085 # include "tao/Cleanup_Func_Registry.inl" 00086 #endif /* __ACE_INLINE__ */ 00087 00088 00089 #include /**/ "ace/post.h" 00090 00091 #endif /* TAO_CLEANUP_FUNC_REGISTRY_H */