summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-09 01:08:18 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-09 01:08:18 +0000
commitfc43836a3bf4ae383f0ded81c5ac48de7a6cad0f (patch)
tree18e47be45191a97344af017d03083ee3db812e41
parent044651e3c0fd5bdd5883a50dbd23005de6107a11 (diff)
downloadATCD-fc43836a3bf4ae383f0ded81c5ac48de7a6cad0f.tar.gz
ChangeLogTag:Thu Jul 08 18:47:23 1999 Kirthika Parameswaran <kirthika@cs.wustl.edu>
-rw-r--r--ChangeLog-99b2
-rw-r--r--ace/Cached_Connect_Strategy_T.cpp2
-rw-r--r--ace/Caching_Utility_T.cpp33
-rw-r--r--ace/Caching_Utility_T.h40
-rw-r--r--ace/Strategies.h18
-rw-r--r--ace/Strategies_T.cpp2
-rw-r--r--ace/Strategies_T.i6
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 <kirthika@cs.wustl.edu>
+
Thu Jul 08 18:47:23 1999 Irfan Pyarali <irfan@cs.wustl.edu>
* 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<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
// Mark the <svc_handler> in the cache as not being <in_use>.
// 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<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::minimum (
////////////////////////////////////////////////////////////////////////////////////////////////////////
+template <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> void
+ACE_Recyclable_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::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 <class KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES> int
ACE_Handler_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, ATTRIBUTES>::clear_cache (CONTAINER &container,
ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *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 KEY, class VALUE, class CONTAINER, class ITERATOR, class ATTRIBUTES>
+class ACE_Recyclable_Handler_Caching_Utility : public ACE_Pair_Caching_Utility<KEY, VALUE, CONTAINER, ITERATOR, 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, Svc_Handler> 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<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::cache_i (
// Mark the <svc_handler> in the cache as not being <in_use>.
// 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<T>::hash_i (void) const
template <class T> ASYS_INLINE int
ACE_Refcounted_Hash_Recyclable<T>::operator== (const ACE_Refcounted_Hash_Recyclable<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.t_;
@@ -372,7 +373,8 @@ ACE_Refcounted_Hash_Recyclable<T>::operator== (const ACE_Refcounted_Hash_Recycla
template <class T> ASYS_INLINE int
ACE_Refcounted_Hash_Recyclable<T>::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;