internal static CacheInternal Create()
 {
     CacheInternal internal2;
     CacheCommon cacheCommon = new CacheCommon();
     int numSingleCaches = 0;
     uint numProcessCPUs = (uint) SystemInfo.GetNumProcessCPUs();
     numSingleCaches = 1;
     numProcessCPUs--;
     while (numProcessCPUs > 0)
     {
         numSingleCaches = numSingleCaches << 1;
         numProcessCPUs = numProcessCPUs >> 1;
     }
     if (numSingleCaches == 1)
     {
         internal2 = new CacheSingle(cacheCommon, null, 0);
     }
     else
     {
         internal2 = new CacheMultiple(cacheCommon, numSingleCaches);
     }
     cacheCommon.SetCacheInternal(internal2);
     cacheCommon.ResetFromConfigSettings();
     return internal2;
 }
Пример #2
0
        internal static CacheInternal Create()
        {
            CacheInternal internal2;
            CacheCommon   cacheCommon     = new CacheCommon();
            int           numSingleCaches = 0;
            uint          numProcessCPUs  = (uint)SystemInfo.GetNumProcessCPUs();

            numSingleCaches = 1;
            numProcessCPUs--;
            while (numProcessCPUs > 0)
            {
                numSingleCaches = numSingleCaches << 1;
                numProcessCPUs  = numProcessCPUs >> 1;
            }
            if (numSingleCaches == 1)
            {
                internal2 = new CacheSingle(cacheCommon, null, 0);
            }
            else
            {
                internal2 = new CacheMultiple(cacheCommon, numSingleCaches);
            }
            cacheCommon.SetCacheInternal(internal2);
            cacheCommon.ResetFromConfigSettings();
            return(internal2);
        }
Пример #3
0
        // common implementation
        static internal CacheInternal Create() {
            CacheCommon cacheCommon = new CacheCommon();
            CacheInternal cacheInternal;
#if USE_MEMORY_CACHE
            if (UseMemoryCache) {
                cacheInternal = new MemCache(cacheCommon);
                cacheCommon.AddSRefTarget(cacheInternal);
            }
            else {
#endif
                int numSubCaches = 0;
                uint numCPUs = (uint) SystemInfo.GetNumProcessCPUs();
                // the number of subcaches is the minimal power of 2 greater
                // than or equal to the number of cpus
                numSubCaches = 1;
                numCPUs -= 1;
                while (numCPUs > 0) {
                    numSubCaches <<= 1;
                    numCPUs >>= 1;
                }
                if (numSubCaches == 1) {
                    cacheInternal = new CacheSingle(cacheCommon, null, 0);
                }
                else {
                    cacheInternal = new CacheMultiple(cacheCommon, numSubCaches);
                }
#if USE_MEMORY_CACHE
            }
#endif
            cacheCommon.SetCacheInternal(cacheInternal);
            cacheCommon.ResetFromConfigSettings();

            return cacheInternal;
        }