[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Jun 22 12:31:57 CDT 2012


branch "master" has been updated
       via  d5f4d6788c674292b7c5a01895d6ef9536ab70dc (commit)
      from  6255e723a6e4315707f362bb8589b29b8896635e (commit)

Summary of changes:
 src/Operations/OperationContextCache.cpp |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit d5f4d6788c674292b7c5a01895d6ef9536ab70dc
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Fri Jun 22 12:31:27 2012 -0500

    The OperationContextCache factory method was altered to allow only one cache with a given TTL.

diff --git a/src/Operations/OperationContextCache.cpp b/src/Operations/OperationContextCache.cpp
index 03c0f25..615ce27 100644
--- a/src/Operations/OperationContextCache.cpp
+++ b/src/Operations/OperationContextCache.cpp
@@ -23,6 +23,9 @@ using namespace AsteriskSCF::System::Logging;
 namespace
 {
 Logger lg = AsteriskSCF::System::Logging::getLoggerFactory().getLogger("AsteriskSCF.Operations");
+
+boost::shared_mutex cacheMapMutex;
+std::map<int, AsteriskSCF::Operations::OperationContextCachePtr> cacheMap;
 }
 
 namespace AsteriskSCF
@@ -127,7 +130,17 @@ private:
  */
 OperationContextCachePtr OperationContextCache::create(int ttlSeconds)
 {
+    boost::unique_lock<boost::shared_mutex> lock(cacheMapMutex);
+
+    std::map<int, OperationContextCachePtr>::iterator i = cacheMap.find(ttlSeconds);
+    if (i != cacheMap.end())
+    {
+        // Only allow one instance with a given TTL per process.
+        return i->second;
+    }
+
     OperationContextCachePtr cache(new OperationContextCache(ttlSeconds));
+    cacheMap[ttlSeconds] = cache;
 
     OperationContextPrunerPtr pruner = new OperationContextPruner(cache, ttlSeconds);
 

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


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



More information about the asterisk-scf-commits mailing list