From 9069014b85ac2be10af32af37e713aff59ca4067 Mon Sep 17 00:00:00 2001 From: irfan Date: Fri, 9 Jul 1999 01:08:18 +0000 Subject: ChangeLogTag:Thu Jul 08 18:47:23 1999 Kirthika Parameswaran --- ChangeLog-99b | 2 ++ ace/Cached_Connect_Strategy_T.cpp | 2 +- ace/Caching_Utility_T.cpp | 33 ++++++++++++++++++++++++++++++++ ace/Caching_Utility_T.h | 40 ++++++++++++++++++++++++++++++--------- ace/Strategies.h | 18 ++++++++++++++---- ace/Strategies_T.cpp | 2 +- ace/Strategies_T.i | 6 ++++-- 7 files changed, 86 insertions(+), 17 deletions(-) diff --git a/ChangeLog-99b b/ChangeLog-99b index 9b4b27fd52f..64bab31ecb1 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,3 +1,5 @@ +Thu Jul 08 18:47:23 1999 Kirthika Parameswaran + Thu Jul 08 18:47:23 1999 Irfan Pyarali * tests/Cache_Map_Manager_Test.cpp: Simplified code and output. diff --git a/ace/Cached_Connect_Strategy_T.cpp b/ace/Cached_Connect_Strategy_T.cpp index 7b5716fdd64..7fb4e9dacef 100644 --- a/ace/Cached_Connect_Strategy_T.cpp +++ b/ace/Cached_Connect_Strategy_T.cpp @@ -345,7 +345,7 @@ ACE_Cached_Connect_Strategy_Ex in the cache as not being . // Therefore recyclable is IDLE. - entry->ext_id_.state (ACE_Recyclable::IDLE); + entry->ext_id_.state (ACE_Recyclable::IDLE_AND_PURGABLE); return 0; } diff --git a/ace/Caching_Utility_T.cpp b/ace/Caching_Utility_T.cpp index 455f336fa7f..226fea96f24 100644 --- a/ace/Caching_Utility_T.cpp +++ b/ace/Caching_Utility_T.cpp @@ -88,6 +88,39 @@ ACE_Pair_Caching_Utility::minimum ( //////////////////////////////////////////////////////////////////////////////////////////////////////// +template void +ACE_Recyclable_Handler_Caching_Utility::minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove) +{ + // Starting values. + ITERATOR iter = container.begin (); + ITERATOR end = container.end (); + ATTRIBUTES min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + + // The iterator moves thru the container searching for the entry + // with the lowest ATTRIBUTES. + for (++iter; + iter != end; + ++iter) + { + if ((*iter).int_id_.first ()->state () == ACE_Recyclable::IDLE_AND_PURGABLE)) + { + if (min > (*iter).int_id_.second ()) + { + // Ah! an item with lower ATTTRIBUTES... + min = (*iter).int_id_.second (); + key_to_remove = &(*iter).ext_id_; + value_to_remove = &(*iter).int_id_; + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// + template int ACE_Handler_Caching_Utility::clear_cache (CONTAINER &container, ACE_Cleanup_Strategy *cleanup_s, diff --git a/ace/Caching_Utility_T.h b/ace/Caching_Utility_T.h index b3264f8841c..542aabff285 100644 --- a/ace/Caching_Utility_T.h +++ b/ace/Caching_Utility_T.h @@ -52,12 +52,34 @@ public: protected: - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); + virtual void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); // Find the entry with minimum caching attributes. }; +//////////////////////////////////////////////////////////////////////////////// + +template +class ACE_Recyclable_Handler_Caching_Utility : public ACE_Pair_Caching_Utility +{ + // = 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 kind. The attributes + // helps in deciding the entries to be purged. +protected: + + virtual void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); + // Find the entry with minimum caching attributes. +}; //////////////////////////////////////////////////////////////////////////////////////// @@ -86,9 +108,9 @@ public: protected: - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); + virtual void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); // 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 @@ -119,9 +141,9 @@ public: protected: - void minimum (CONTAINER &container, - KEY *&key_to_remove, - VALUE *&value_to_remove); + virtual void minimum (CONTAINER &container, + KEY *&key_to_remove, + VALUE *&value_to_remove); // 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 diff --git a/ace/Strategies.h b/ace/Strategies.h index 91694238900..474c23503ac 100644 --- a/ace/Strategies.h +++ b/ace/Strategies.h @@ -116,10 +116,20 @@ class ACE_Export ACE_Recyclable public: enum State { - IDLE, - BUSY, - CLOSED, - UNKNOWN + IDLE_AND_PURGABLE, + // Idle and can be purged. + + IDLE_BUT_NOT_PURGABLE, + // Idle but cannot be purged. + + BUSY = 2, + // Busy (i.e., cannot be recycled or purged). + + CLOSED = 3, + // Closed. + + UNKNOWN = 4 + // Unknown state. }; virtual ~ACE_Recyclable (void); diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index 73b4dfb579b..5bacb3db45e 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -823,7 +823,7 @@ ACE_Cached_Connect_Strategy::cache_i ( // Mark the in the cache as not being . // Therefore recyclable is IDLE. - entry->ext_id_.state (ACE_Recyclable::IDLE); + entry->ext_id_.state (ACE_Recyclable::IDLE_AND_PURGABLE); return 0; } diff --git a/ace/Strategies_T.i b/ace/Strategies_T.i index c456700a6f3..20b7103681c 100644 --- a/ace/Strategies_T.i +++ b/ace/Strategies_T.i @@ -363,7 +363,8 @@ ACE_Refcounted_Hash_Recyclable::hash_i (void) const template ASYS_INLINE int ACE_Refcounted_Hash_Recyclable::operator== (const ACE_Refcounted_Hash_Recyclable &rhs) const { - if (this->state () != ACE_Recyclable::IDLE) + if (this->state () != ACE_Recyclable::IDLE_AND_PURGABLE || + this->state () != ACE_Recyclable::IDLE_BUT_NOT_PURGABLE) return 0; else return this->t_ == rhs.t_; @@ -372,7 +373,8 @@ ACE_Refcounted_Hash_Recyclable::operator== (const ACE_Refcounted_Hash_Recycla template ASYS_INLINE int ACE_Refcounted_Hash_Recyclable::operator== (const T &rhs) const { - if (this->state () != ACE_Recyclable::IDLE) + if (this->state () != ACE_Recyclable::IDLE_AND_PURGABLE || + this->state () != ACE_Recyclable::IDLE_BUT_NOT_PURGABLE) return 0; else return this->t_ == rhs; -- cgit v1.2.1