[asterisk-scf-commits] asterisk-scf/integration/ice-util-cpp.git branch "retry_deux" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Feb 1 13:44:15 CST 2012


branch "retry_deux" has been updated
       via  f8321e105ea059622ad3f1ba1690e9f7f581a8f8 (commit)
      from  4cf6a1608548d00b6cdd06b683648b38aa44c64d (commit)

Summary of changes:
 .../AsteriskSCF/Helpers/OperationContextCache.h    |    7 ++++++-
 src/Helpers/OperationContextCache.cpp              |   16 ++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit f8321e105ea059622ad3f1ba1690e9f7f581a8f8
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Wed Feb 1 13:43:43 2012 -0600

    Minor corrections to cache.

diff --git a/include/AsteriskSCF/Helpers/OperationContextCache.h b/include/AsteriskSCF/Helpers/OperationContextCache.h
index 6bbbb00..2470981 100644
--- a/include/AsteriskSCF/Helpers/OperationContextCache.h
+++ b/include/AsteriskSCF/Helpers/OperationContextCache.h
@@ -39,7 +39,7 @@ public:
      * ctor
      * @param ttlMinutes  The time-to-live for the OperationContexts being cached.
      * Entries will remain in the cache for at least the provided value, but can 
-     * be longer. 
+     * remain in cache longer. 
      */
     OperationContextCache(int ttlMinutes);
     ~OperationContextCache();
@@ -57,6 +57,11 @@ public:
      */
     bool contains(const AsteriskSCF::System::V1::OperationContextPtr& operationContext);
 
+    /**
+     * Drop entries that are older than the TTL. 
+     * @note This method is called by an internal timer task, so clients
+     * of this class don't need to call it unless they just want to. 
+     */
     void prune(); 
 
 private:
diff --git a/src/Helpers/OperationContextCache.cpp b/src/Helpers/OperationContextCache.cpp
index 981c885..3c6085f 100644
--- a/src/Helpers/OperationContextCache.cpp
+++ b/src/Helpers/OperationContextCache.cpp
@@ -30,6 +30,11 @@ namespace Helpers
 class OperationContextCachEntry : IceUtil::Shared
 {
 public:
+    /**
+     * ctor
+     * @param context The context to wrap.
+     * @param ttl The time-to-live to use in isStale() tests. 
+     */
     OperationContextCachEntry(const OperationContextPtr& context, const IceUtil::Time& ttl) :
       mContext(context),
       mTimestamp(IceUtil::Time::now()),
@@ -48,7 +53,7 @@ public:
      */
     bool isStale(const IceUtil::Time& now)
     {
-        if (now - mTimestamp > mTTL)
+        if ((now - mTimestamp) > mTTL)
         {
             return true;
         }
@@ -68,6 +73,7 @@ class OperationContextPruner : public IceUtil::TimerTask
 {
 public:
     OperationContextPruner(const OperationContextCachePtr& cache)
+        : mCache(cache)
     {
     }
 
@@ -150,18 +156,20 @@ void OperationContextCache::prune()
     std::map<std::string, OperationContextCachEntryPtr>::const_iterator cacheIter;
 
     IceUtil::Time now(IceUtil::Time::now());
-    std::vector<std::string> purgeList;
+    std::vector<std::string> staleList;
 
+    // Build list of stale items.
     for(cacheIter = mCache.begin(); cacheIter != mCache.end(); cacheIter++)
     {
         if (cacheIter->second->isStale(now))
         {
-            purgeList.push_back(cacheIter->first);
+            staleList.push_back(cacheIter->first);
         }
     }
 
+    // Drop the stale items from the cache.
     std::vector<std::string>::const_iterator purgeIter;
-    for (purgeIter = purgeList.begin(); purgeIter != purgeList.end(); purgeIter++)
+    for (purgeIter = staleList.begin(); purgeIter != staleList.end(); purgeIter++)
     {
         mCache.erase(*purgeIter);
     }

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list