Esempio n. 1
0
        private void DoIt(
            uint nInstances,
            int nLoops,
            MapMemTypes mapfileType = MapMemTypes.MapMemTypePageFile,
            bool fDoDeleteStuff     = false,
            bool fUseNormDict       = false
            )
        {
            Assert.AreEqual(IntPtr.Size, 4, "intptr != 4?");
            for (uint iLoop = 0; iLoop < nLoops; iLoop++)
            {
                uint ulInitialFileSize = 0;

                if (fDoDeleteStuff)
                {
                }
                IDictionary <int, DataClass> dict;
                using (var mfd = new MapFileDict <int, DataClass>(ulInitialSize: ulInitialFileSize, mapfileType: mapfileType))
                {
                    if (fUseNormDict)//|| true)
                    {
                        dict = new Dictionary <int, DataClass>();
                    }
                    else
                    {
                        dict = mfd;
                    }
                    try
                    {
                        //                    Assert.IsTrue(mfd._objSize == 36, "obj size = 36");
                        for (int i = 00; i < nInstances; i++)
                        {
                            var testInstance = DataClass.MakeInstance((ulong)i);
                            dict[(int)i] = testInstance;
                            var res = i;

                            var retrievedInstance = dict[(int)i];
                            Assert.AreEqual(testInstance, retrievedInstance, "objects not equal Count=" + dict.Count.ToString());
                            if (fDoDeleteStuff)
                            {
                            }
                        }
                        for (int i = 00; i < nInstances; i++)
                        {
                            var retrievedInstance = dict[i];
                            var testInstance      = DataClass.MakeInstance((ulong)i);
                            Assert.AreEqual(testInstance, retrievedInstance, "objects not equal Count=" + dict.Count.ToString());
                        }
                        //dict.Clear();
                        mfd.VerifyNoLeaks();
                    }
                    catch (Exception ex)
                    {
                        mfd.Dispose();
                        Assert.Fail("exception lp={0} cnt={1} {2}\r\n{3}", iLoop, mfd.Count, mfd._MemMap._stats.ToString(), ex.ToString());
                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
 public MapFileList(
     ulong ulInitialSize              = 0,
     MapMemTypes mapfileType          = MapMemTypes.MapMemTypePageFile,
     ulong ulGrowDynamicallyThreshold = 0,
     MemMap memMapToUse = null,
     uint uiViewSize    = MemMap.AllocationGranularity
     )
 {
     _MemMap = memMapToUse;
     if (_MemMap == null)
     {
         _MemMap = new MemMap(
             ulInitialSize,
             mapfileType,
             ulGrowDynamicallyThreshold,
             uiViewSize
             );
     }
     _listInternal = new List <MHandle>();
 }
Esempio n. 3
0
 public MapFileDict(
     IEqualityComparer <TKey> comparer = null,
     ulong ulInitialSize              = 0,
     MapMemTypes mapfileType          = MapMemTypes.MapMemTypePageFile,
     ulong ulGrowDynamicallyThreshold = 0,
     MemMap memMapToUse = null,
     uint uiViewSize    = MemMap.AllocationGranularity
     )
 {
     _MemMap   = memMapToUse;
     _comparer = comparer ?? EqualityComparer <TKey> .Default;
     if (_MemMap == null)
     {
         _MemMap = new MemMap(
             ulInitialSize,
             mapfileType,
             ulGrowDynamicallyThreshold,
             uiViewSize
             );
     }
 }