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.cpp307
1 files changed, 88 insertions, 219 deletions
diff --git a/ace/Caching_Strategies_T.cpp b/ace/Caching_Strategies_T.cpp
index 72d5e1ab953..ad5821b81d0 100644
--- a/ace/Caching_Strategies_T.cpp
+++ b/ace/Caching_Strategies_T.cpp
@@ -15,44 +15,30 @@
ACE_RCSID(ace, Caching_Strategies_T, "$Id$")
-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,
- int delete_caching_strategy_utility)
+template<class CONTAINER>
+ACE_LRU_Caching_Strategy<CONTAINER>::ACE_LRU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
: timer_ (0),
purge_percent_ (10),
entries_ (0),
cleanup_strategy_ (0),
- delete_cleanup_strategy_ (1),
- caching_strategy_utility_ (0),
- delete_caching_strategy_utility_ (1)
+ delete_cleanup_strategy_ (1)
{
- if (this->open (cleanup_s,
- delete_cleanup_strategy,
- utility_s,
- delete_caching_strategy_utility) == -1)
+ if (this->open (cleanup_s, delete_cleanup_strategy) == -1)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
ASYS_TEXT ("ACE_LRU_Caching_Strategy::ACE_LRU_Caching_Strategy")));
-
+
}
-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 (void)
+template<class CONTAINER>
+ACE_LRU_Caching_Strategy<CONTAINER>::~ACE_LRU_Caching_Strategy (void)
{
- if (this->delete_cleanup_strategy_ == 1)
- delete this->cleanup_strategy_;
-
- if (this->delete_caching_strategy_utility_ == 1)
- delete this->caching_strategy_utility_;
}
-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>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER> int
+ACE_LRU_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
{
// Initialise the cleanup strategy.
@@ -60,103 +46,67 @@ ACE_LRU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
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_ = delete_cleanup_strategy;
+
}
if (cleanup_s != 0)
this->cleanup_strategy_ = cleanup_s;
else if (this->cleanup_strategy_ == 0)
{
+
ACE_NEW_RETURN (this->cleanup_strategy_,
CLEANUP_STRATEGY,
-1);
this->delete_cleanup_strategy_ = delete_cleanup_strategy;
- }
- // Initialise the caching strategy utility.
-
- // First we decide whether we need to clean up.
- if (this->caching_strategy_utility_ != 0 &&
- this->delete_caching_strategy_utility_ == 1 &&
- utility_s != 0)
- {
- delete this->caching_strategy_utility_;
- this->caching_strategy_utility_ = 0;
- this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
-
- if (utility_s != 0)
- 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_ = delete_caching_strategy_utility;
- }
-
- return 0;
+
+ return 0;
}
-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)
+template<class CONTAINER> int
+ACE_LRU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container)
{
- return this->caching_strategy_utility_->clear_cache (container,
- this->cleanup_strategy_,
- 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);
+ return this->caching_strategy_utility_.clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ this->entries_);
}
-
+
////////////////////////////////////////////////////////////////////////////////////////////////
-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 (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER>
+ACE_LFU_Caching_Strategy<CONTAINER>::ACE_LFU_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
: purge_percent_ (10),
entries_ (0),
cleanup_strategy_ (0),
- delete_cleanup_strategy_ (1),
- caching_strategy_utility_ (0),
- delete_caching_strategy_utility_ (1)
+ delete_cleanup_strategy_ (1)
{
- if (this->open (cleanup_s,
- delete_cleanup_strategy,
- utility_s,
- delete_caching_strategy_utility) == -1)
+ if (this->open (cleanup_s, delete_cleanup_strategy) == -1)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
ASYS_TEXT ("ACE_LFU_Caching_Strategy::ACE_LFU_Caching_Strategy")));
-
+
}
-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)
+template<class CONTAINER>
+ACE_LFU_Caching_Strategy<CONTAINER>::~ACE_LFU_Caching_Strategy (void)
{
}
-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>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER> int
+ACE_LFU_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
{
// Initialise the cleanup strategy.
@@ -165,102 +115,67 @@ ACE_LFU_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTI
this->delete_cleanup_strategy_ == 1 &&
cleanup_s != 0)
{
+
delete this->cleanup_strategy_;
+
this->cleanup_strategy_ = 0;
+
this->delete_cleanup_strategy_ = delete_cleanup_strategy;
+
}
if (cleanup_s != 0)
this->cleanup_strategy_ = cleanup_s;
else if (this->cleanup_strategy_ == 0)
{
+
ACE_NEW_RETURN (this->cleanup_strategy_,
CLEANUP_STRATEGY,
-1);
this->delete_cleanup_strategy_ = delete_cleanup_strategy;
- }
-
- // Initialise the caching strategy utility.
-
- // First we decide whether we need to clean up.
- if (this->caching_strategy_utility_ != 0 &&
- this->delete_caching_strategy_utility_ == 1 &&
- utility_s != 0)
- {
- delete this->caching_strategy_utility_;
- this->caching_strategy_utility_ = 0;
- this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
- }
- if (utility_s != 0)
- 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_ = delete_caching_strategy_utility;
}
-
+
return 0;
}
-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)
+template<class CONTAINER> int
+ACE_LFU_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container)
{
- return this->caching_strategy_utility_->clear_cache (container,
- this->cleanup_strategy_,
- 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);
+ return this->caching_strategy_utility_.clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ this->entries_);
}
////////////////////////////////////////////////////////////////////////////////////////////////
-template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
-ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER>
+ACE_FIFO_Caching_Strategy<CONTAINER>::ACE_FIFO_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
: order_ (0),
purge_percent_ (10),
entries_ (0),
cleanup_strategy_ (0),
- delete_cleanup_strategy_ (1),
- caching_strategy_utility_ (0),
- delete_caching_strategy_utility_ (1)
+ delete_cleanup_strategy_ (1)
{
- if (this->open (cleanup_s,
- delete_cleanup_strategy,
- utility_s,
- delete_caching_strategy_utility) == -1)
+ if (this->open (cleanup_s, delete_cleanup_strategy) == -1)
ACE_ERROR ((LM_ERROR,
ASYS_TEXT ("%p\n"),
ASYS_TEXT ("ACE_FIFO_Caching_Strategy::ACE_FIFO_Caching_Strategy")));
}
-template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
-ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_FIFO_Caching_Strategy (void)
+template<class CONTAINER>
+ACE_FIFO_Caching_Strategy<CONTAINER>::~ACE_FIFO_Caching_Strategy (void)
{
}
-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>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER> int
+ACE_FIFO_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
{
// Initialise the cleanup strategy.
@@ -269,116 +184,68 @@ ACE_FIFO_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UT
this->delete_cleanup_strategy_ == 1 &&
cleanup_s != 0)
{
+
delete this->cleanup_strategy_;
+
this->cleanup_strategy_ = 0;
+
this->delete_cleanup_strategy_ = delete_cleanup_strategy;
+
}
if (cleanup_s != 0)
this->cleanup_strategy_ = cleanup_s;
else if (this->cleanup_strategy_ == 0)
{
+
ACE_NEW_RETURN (this->cleanup_strategy_,
- CLEANUP_STRATEGY,
+ CLEANUP_STRATEGY,
-1);
this->delete_cleanup_strategy_ = delete_cleanup_strategy;
- }
-
- // Initialise the caching strategy utility.
- // First we decide whether we need to clean up.
- if (this->caching_strategy_utility_ != 0 &&
- this->delete_caching_strategy_utility_ == 1 &&
- utility_s != 0)
- {
- delete this->caching_strategy_utility_;
- this->caching_strategy_utility_ = 0;
- this->delete_caching_strategy_utility_ = delete_caching_strategy_utility;
}
+
+ return 0;
+}
- if (utility_s != 0)
- 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_ = delete_caching_strategy_utility;
- }
- return 0;
-}
-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)
+template<class CONTAINER> int
+ACE_FIFO_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container)
{
- return this->caching_strategy_utility_->clear_cache (container,
- this->cleanup_strategy_,
- 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);
+ return this->caching_strategy_utility_.clear_cache (container,
+ this->cleanup_strategy_,
+ this->purge_percent_,
+ this->entries_);
}
+
////////////////////////////////////////////////////////////////////////////////////////////////
-template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
-ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER>
+ACE_Null_Caching_Strategy<CONTAINER>::ACE_Null_Caching_Strategy (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
{
- ACE_UNUSED_ARG (cleanup_s);
- ACE_UNUSED_ARG (delete_cleanup_strategy);
- ACE_UNUSED_ARG (utility_s);
- ACE_UNUSED_ARG (delete_caching_strategy_utility);
}
-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>::open (ACE_Cleanup_Strategy<KEY, VALUE, CONTAINER> *cleanup_s,
- int delete_cleanup_strategy,
- CACHING_STRATEGY_UTILITY *utility_s,
- int delete_caching_strategy_utility)
+template<class CONTAINER> int
+ACE_Null_Caching_Strategy<CONTAINER>::open (ACE_Cleanup_Strategy<CONTAINER> *cleanup_s,
+ int delete_cleanup_strategy)
{
- ACE_UNUSED_ARG (cleanup_s);
- ACE_UNUSED_ARG (delete_cleanup_strategy);
- ACE_UNUSED_ARG (utility_s);
- ACE_UNUSED_ARG (delete_caching_strategy_utility);
-
- return 0;
}
-template<class KEY, class VALUE, class CONTAINER, class ATTRIBUTES, class CACHING_STRATEGY_UTILITY>
-ACE_Null_Caching_Strategy<KEY, VALUE, CONTAINER, ATTRIBUTES, CACHING_STRATEGY_UTILITY>::~ACE_Null_Caching_Strategy (void)
+template<class CONTAINER>
+ACE_Null_Caching_Strategy<CONTAINER>::~ACE_Null_Caching_Strategy (void)
{
}
-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)
+template<class CONTAINER> int
+ACE_Null_Caching_Strategy<CONTAINER>::clear_cache (CONTAINER &container)
{
- ACE_UNUSED_ARG (container);
-
- 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;
}
@@ -388,5 +255,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy)
ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy)
-
#endif /* CACHING_STRATEGIES_T_C */
+
+
+