summaryrefslogtreecommitdiff
path: root/ace/Caching_Strategies_T.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Caching_Strategies_T.cpp')
-rw-r--r--ace/Caching_Strategies_T.cpp108
1 files changed, 58 insertions, 50 deletions
diff --git a/ace/Caching_Strategies_T.cpp b/ace/Caching_Strategies_T.cpp
index 532064ae23e..72d5e1ab953 100644
--- a/ace/Caching_Strategies_T.cpp
+++ b/ace/Caching_Strategies_T.cpp
@@ -16,13 +16,6 @@
ACE_RCSID(ace, Caching_Strategies_T, "$Id$")
template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
-ACE_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_Caching_Strategy (void)
-{
-}
-
-//////////////////////////////////////////////////////////////////////////////////
-
-template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
int delete_cleanup_strategy,
CACHING_STRATEGY_UTILITY *utility_s,
@@ -50,13 +43,9 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
{
if (this->delete_cleanup_strategy_ == 1)
delete this->cleanup_strategy_;
- this->delete_cleanup_strategy_ = 0;
- this->cleanup_strategy_ = 0;
if (this->delete_caching_strategy_utility_ == 1)
delete this->caching_strategy_utility_;
- this->delete_caching_strategy_utility_ = 0;
- this->caching_strategy_utility_ = 0;
}
template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
@@ -68,27 +57,24 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
// Initialise the cleanup strategy.
// First we decide whether we need to clean up.
- if (this->cleanup_strategy_ != 0 &&
+ if (this->cleanup_strategy_ != 0 &&
this->delete_cleanup_strategy_ == 1 &&
cleanup_s != 0)
{
delete this->cleanup_strategy_;
this->cleanup_strategy_ = 0;
- this->delete_cleanup_strategy_ = 0;
+ this->delete_cleanup_strategy_ = delete_cleanup_strategy;
}
if (cleanup_s != 0)
- {
- this->cleanup_strategy_ = cleanup_s;
- this->delete_cleanup_strategy_ = delete_cleanup_strategy;
- }
+ this->cleanup_strategy_ = cleanup_s;
else if (this->cleanup_strategy_ == 0)
{
ACE_NEW_RETURN (this->cleanup_strategy_,
CLEANUP_STRATEGY,
-1);
- this->delete_cleanup_strategy_ = 1;
+ this->delete_cleanup_strategy_ = delete_cleanup_strategy;
}
// Initialise the caching strategy utility.
@@ -100,21 +86,18 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
{
delete this->caching_strategy_utility_;
this->caching_strategy_utility_ = 0;
- this->delete_caching_strategy_utility_ = 0;
+ this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
if (utility_s != 0)
- {
- this->caching_strategy_utility_ = utility_s;
- this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
- }
+ this->caching_strategy_utility_ = utility_s;
else if (this->caching_strategy_utility_ == 0)
{
ACE_NEW_RETURN (this->caching_strategy_utility_,
CACHING_STRATEGY_UTILITY,
-1);
- this->delete_caching_strategy_utility_ = 1;
+ this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
return 0;
@@ -125,7 +108,19 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
{
return this->caching_strategy_utility_->clear_cache (container,
this->cleanup_strategy_,
- this->purge_percent_);
+ this->purge_percent_,
+ this->entries_);
+}
+
+template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
+ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container,
+ unsigned int &total_container_entries)
+{
+
+ return this->caching_strategy_utility_->clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ total_container_entries);
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -155,15 +150,6 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_LFU_Caching_Strategy (void)
{
- if (this->delete_cleanup_strategy_ == 1)
- delete this->cleanup_strategy_;
- this->delete_cleanup_strategy_ = 0;
- this->cleanup_strategy_ = 0;
-
- if (this->delete_caching_strategy_utility_ == 1)
- delete this->caching_strategy_utility_;
- this->delete_caching_strategy_utility_ = 0;
- this->caching_strategy_utility_ = 0;
}
template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
@@ -192,7 +178,7 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
CLEANUP_STRATEGY,
-1);
- this->delete_cleanup_strategy_ = 1;
+ this->delete_cleanup_strategy_ = delete_cleanup_strategy;
}
// Initialise the caching strategy utility.
@@ -215,7 +201,7 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
CACHING_STRATEGY_UTILITY,
-1);
- this->delete_caching_strategy_utility_ = 1;
+ this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
return 0;
@@ -226,9 +212,19 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
{
return this->caching_strategy_utility_->clear_cache (container,
this->cleanup_strategy_,
- this->purge_percent_);
+ this->purge_percent_,
+ this->entries_);
}
+template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
+ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container,
+ unsigned int &total_container_entries)
+{
+ return this->caching_strategy_utility_->clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ total_container_entries);
+}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -258,15 +254,6 @@ template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHIN
ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_FIFO_Caching_Strategy (void)
{
- if (this->delete_cleanup_strategy_ == 1)
- delete this->cleanup_strategy_;
- this->delete_cleanup_strategy_ = 0;
- this->cleanup_strategy_ = 0;
-
- if (this->delete_caching_strategy_utility_ == 1)
- delete this->caching_strategy_utility_;
- this->delete_caching_strategy_utility_ = 0;
- this->caching_strategy_utility_ = 0;
}
template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
@@ -295,7 +282,7 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
CLEANUP_STRATEGY,
-1);
- this->delete_cleanup_strategy_ = 1;
+ this->delete_cleanup_strategy_ = delete_cleanup_strategy;
}
// Initialise the caching strategy utility.
@@ -318,7 +305,7 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
CACHING_STRATEGY_UTILITY,
-1);
- this->delete_caching_strategy_utility_ = 1;
+ this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
return 0;
@@ -329,7 +316,18 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
{
return this->caching_strategy_utility_->clear_cache (container,
this->cleanup_strategy_,
- this->purge_percent_);
+ this->purge_percent_,
+ this->entries_);
+}
+
+template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
+ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container,
+ unsigned int &total_container_entries)
+{
+ return this->caching_strategy_utility_->clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ total_container_entries);
}
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -357,7 +355,7 @@ ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
ACE_UNUSED_ARG (delete_cleanup_strategy);
ACE_UNUSED_ARG (utility_s);
ACE_UNUSED_ARG (delete_caching_strategy_utility);
-
+
return 0;
}
@@ -374,6 +372,16 @@ ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
return 0;
}
+template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY> int
+ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::clear_cache (CONTAINER &container,
+ unsigned int &total_container_entries)
+{
+ ACE_UNUSED_ARG (container);
+ ACE_UNUSED_ARG (total_container_entries);
+
+ return 0;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy)