summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 23:19:27 +0000
committerkirthika <kirthika@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 23:19:27 +0000
commitca6fd5ce694fe083c66bfa733f3b4d89f9e84ceb (patch)
treeebb71f3ca35665444fa323f568b088656b671e6c
parent84232d6e0f6902dbe2eb9c21093215182e94c2d9 (diff)
downloadATCD-ca6fd5ce694fe083c66bfa733f3b4d89f9e84ceb.tar.gz
Handler_Cleanup_Strategy added.
-rw-r--r--ace/Cleanup_Strategies_T.cpp54
-rw-r--r--ace/Cleanup_Strategies_T.h52
2 files changed, 75 insertions, 31 deletions
diff --git a/ace/Cleanup_Strategies_T.cpp b/ace/Cleanup_Strategies_T.cpp
index 4afa343e84a..b1d45ecc116 100644
--- a/ace/Cleanup_Strategies_T.cpp
+++ b/ace/Cleanup_Strategies_T.cpp
@@ -12,32 +12,32 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined (ACE_LACKS_INLINE_FUNCTIONS)
-#include "ace/Cached_Connect_Strategy_T.i"
+#include "ace/Cleanup_Strategies_T.i"
#endif /* ACE_LACKS_INLINE_FUNCTIONS */
ACE_RCSID(ace, Cleanup_Strategies_T, "$Id$")
-template <class CONTAINER>
-ACE_Cleanup_Strategy<CONTAINER>::~ACE_Cleanup_Strategy (void)
+template <class KEY, class VALUE, class CONTAINER>
+ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>::~ACE_Cleanup_Strategy (void)
{
}
////////////////////////////////////////////////////////////////////////////
-template <class CONTAINER> int
-ACE_Default_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container,
- KEY *key,
- VALUE *value)
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Default_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
+ KEY *key,
+ VALUE *value)
{
return container.unbind (*key);
}
////////////////////////////////////////////////////////////////////////////
-template <class CONTAINER> int
-ACE_Svc_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container,
- KEY *key,
- VALUE *value)
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Svc_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
+ KEY *key,
+ VALUE *value)
{
(value->first ())->recycler (0, 0);
@@ -50,11 +50,35 @@ ACE_Svc_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container,
}
/////////////////////////////////////////////////////////////////////////////
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Handler_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
+ KEY *key,
+ VALUE *value)
+{
+ // Remove the item from cache only if the handler isnt in use.
+ if ((*value)->active () == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "handle %d\n",
+ (*value)->get_handle ()));
+ (*value)->close ();
+
+ ACE_DEBUG ((LM_DEBUG, "LRU: before unbind: current_size %d\n", container.current_size ()));
+
+ if (container.unbind (*key) == -1)
+ return -1;
-template <class CONTAINER> int
-ACE_Null_Cleanup_Strategy<CONTAINER>::cleanup (CONTAINER &container,
- KEY *key,
- VALUE *value)
+ ACE_DEBUG ((LM_DEBUG, "LRU:after unbind: current_size %d\n", container.current_size ()));
+ }
+
+ return 0;
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+template <class KEY, class VALUE, class CONTAINER> int
+ACE_Null_Cleanup_Strategy<KEY, VALUE, CONTAINER>::cleanup (CONTAINER &container,
+ KEY *key,
+ VALUE *value)
{
return 0;
}
diff --git a/ace/Cleanup_Strategies_T.h b/ace/Cleanup_Strategies_T.h
index 4cdeec27b24..05e51ce29de 100644
--- a/ace/Cleanup_Strategies_T.h
+++ b/ace/Cleanup_Strategies_T.h
@@ -23,7 +23,7 @@
#define ACE_LACKS_PRAGMA_ONCE
#endif /* ACE_LACKS_PRAGMA_ONCE */
-template <class CONTAINER>
+template <class KEY, class VALUE, class CONTAINER>
class ACE_Cleanup_Strategy
{
// = TITLE
@@ -35,11 +35,7 @@ class ACE_Cleanup_Strategy
// can be decoupled from other strategies which need to do it.
// The cleanup method provided needs to be implemented as needed.
- public:
-
- // Traits.
- typedef ACE_TYPENAME CONTAINER::KEY KEY;
- typedef ACE_TYPENAME CONTAINER::VALUE VALUE;
+ public:
// = Termination.
@@ -55,8 +51,8 @@ class ACE_Cleanup_Strategy
//////////////////////////////////////////////////////////////////////////
-template <class CONTAINER>
-class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
+template <class KEY, class VALUE, class CONTAINER>
+class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>
{
// = TITLE
// Defines a default strategy to be followed for cleaning up
@@ -67,15 +63,15 @@ class ACE_Default_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
// container.
public:
-
+
virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value);
// The method which will do the cleanup of the entry in the container.
};
//////////////////////////////////////////////////////////////////////
-template <class CONTAINER>
-class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
+template <class KEY, class VALUE, class CONTAINER>
+class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>
{
// = TITLE
// Defines a strategy to be followed for cleaning up
@@ -84,10 +80,33 @@ class ACE_Svc_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
// = DESCRIPTION
// The entry to be cleaned up is removed from the container.
// Here, since we are dealing with svc_handlers specifically, we
- // perform a couple of extra operations.
+ // perform a couple of extra operations. Note: To be used when
+ // the handler is recyclable.
public:
+
+ virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value);
+ // The method which will do the cleanup of the entry in the container.
+
+};
+//////////////////////////////////////////////////////////////////////
+template <class KEY, class VALUE, class CONTAINER>
+class ACE_Handler_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>
+{
+ // = TITLE
+ // Defines a strategy to be followed for cleaning up
+ // entries which are svc_handlers from a container.
+ //
+ // = DESCRIPTION
+ // The entry to be cleaned up is removed from the container.
+ // Here, since we are dealing with svc_handlers specifically, we
+ // perform a couple of extra operations. Note: This cleanup strategy
+ // should be used in the case when the handler has the caching
+ // attributes.
+
+public:
+
virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value);
// The method which will do the cleanup of the entry in the container.
@@ -95,8 +114,9 @@ public:
//////////////////////////////////////////////////////////////////////
-template <class CONTAINER>
-class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
+
+template <class KEY, class VALUE, class CONTAINER>
+class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER>
{
// = TITLE
// Defines a do-nothing implementation of the cleanup strategy.
@@ -106,9 +126,9 @@ class ACE_Null_Cleanup_Strategy : public ACE_Cleanup_Strategy<CONTAINER>
// the effect of the Cleanup Strategy.
public:
-
+
virtual int cleanup (CONTAINER &container, KEY *key, VALUE *value);
- // the dummy cleanup method.
+ // The dummy cleanup method.
};