diff options
Diffstat (limited to 'ace/Caching_Strategy_Utility_T.h')
-rw-r--r-- | ace/Caching_Strategy_Utility_T.h | 139 |
1 files changed, 17 insertions, 122 deletions
diff --git a/ace/Caching_Strategy_Utility_T.h b/ace/Caching_Strategy_Utility_T.h index 4375fcf3048..df9673498c1 100644 --- a/ace/Caching_Strategy_Utility_T.h +++ b/ace/Caching_Strategy_Utility_T.h @@ -18,48 +18,18 @@ #define CACHING_STRATEGY_UTILITY_H #include "ace/OS.h" +#include <math.h> #if !defined (ACE_LACKS_PRAGMA_ONCE) #define ACE_LACKS_PRAGMA_ONCE #endif /* ACE_LACKS_PRAGMA_ONCE */ // Forward declaration -template <class KEY, class VALUE, class CONTAINER> +template <class CONTAINER> class ACE_Cleanup_Strategy; -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Caching_Strategy_Utility -{ - // = TITLE - // Defines a abstract helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - - public: - - virtual ~ACE_Caching_Strategy_Utility (void); - // Destructor. - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries) = 0; - // This method will remove the entries from the cache. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value) = 0; - // Find the entry with minimum caching attributes. - -}; - -//////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Svc_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility<KEY, VALUE, CONTAINER, ATTRIBUTES> +template <class CONTAINER, class ATTRIBUTES> +class ACE_Caching_Strategy_Utility { // = TITLE // Defines a helper class for the Caching Strategies. @@ -68,102 +38,27 @@ class ACE_Svc_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility<KEY // This class defines the methods commonly used by the // different caching strategies. For instance: clear_cache () // method which decides and purges the entry from the container. - // Note: This class helps in the caching_strategies using a - // container containing entries of <KEY, ACE_Pair<VALUE, - // attributes>> kind. The attributes helps in deciding the - // entries to be purged. public: - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); - // Find the entry with minimum caching attributes. - -}; - - -//////////////////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Handler_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility <KEY, VALUE, CONTAINER, ATTRIBUTES> -{ - // = TITLE - // Defines a helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - // Note: This class helps in the caching_strategies using a - // container containing entries of <KEY, HANDLER> kind where the - // HANDLER contains the caching attributes which help in deciding - // the entries to be purged. - -public: - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. - - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); - // Find the entry with minimum caching attributes. - // This is handler specific since this utility is to be used very - // specifically for handler who have caching_attributes for server - // side acched connection management. - -}; - -/////////////////////////////////////////////////////////////////////////// - -template <class KEY, class VALUE, class CONTAINER, class ATTRIBUTES> -class ACE_Null_Caching_Strategy_Utility : public ACE_Caching_Strategy_Utility <KEY, VALUE, CONTAINER, ATTRIBUTES> -{ - // = TITLE - // Defines a dummy helper class for the Caching Strategies. - // - // = DESCRIPTION - // This class defines the methods commonly used by the - // different caching strategies. For instance: clear_cache () - // method which decides and purges the entry from the container. - // Note: This class is be used with the Null_Caching_Strategy. - -public: - - virtual int clear_cache (CONTAINER &container, - ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s, - const unsigned int purge_percent, - unsigned int &entries); - // Purge entries from the <container>. The Cleanup_Strategy will do - // the actual job of cleanup once the entries to be cleaned up are - // decided. NOte: Here it is a no-op. + // = Traits. + typedef ACE_TYPENAME CONTAINER::KEY KEY; + typedef ACE_TYPENAME CONTAINER::VALUE VALUE; + + int clear_cache (CONTAINER &container, + ACE_Cleanup_Strategy<CONTAINER> *cleanup_s, + const unsigned int purge_percent, + unsigned int &entries); + // Purge entries from the <container>. The <entries> had to be + // passed by refernce as it wuold reduce on cleanup. - virtual void minimum (CONTAINER &container, - KEY *&key, - VALUE *&value); + void minimum (CONTAINER &container, + KEY *&key, + VALUE *&value); // Find the entry with minimum caching attributes. - // This is handler specific since this utility is to be used very - // specifically for handler who have caching_attributes for server - // side acched connection management.Note: Here it is a no-op. }; -/////////////////////////////////////////////////////////////////////////// - #if defined (__ACE_INLINE__) #include "ace/Caching_Strategy_Utility_T.i" #endif /* __ACE_INLINE__ */ |