コード例 #1
0
        public void AllocatorMutex()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#C01");

            AprPool p = AprPool.Create(a);

            Assert.IsFalse(p.IsNull, "#C02");
            Assert.AreEqual(((IntPtr)a).ToInt32(), ((IntPtr)(p.Allocator)).ToInt32(), "#C03");

            a.Owner = p;
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(a.Owner)).ToInt32(), "#C04");

            AprThreadMutex m = AprThreadMutex.Create(p);

            Assert.IsFalse(m.IsNull, "#C05");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(m.Pool)).ToInt32(), "#C06");

            a.Mutex = m;
            Assert.AreEqual(((IntPtr)m).ToInt32(), ((IntPtr)(a.Mutex)).ToInt32(), "#C07");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C08");
        }
コード例 #2
0
        public void CreateDestroySubPoolWithCustomAllocator()
        {
            AprPool p = new AprPool();

            Assert.IsTrue(p.IsNull, "#D01");

            p = AprPool.Create();
            Assert.IsFalse(p.IsNull, "#D02");

            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#D03");

            AprPool sp = AprPool.Create(p, a);

            Assert.IsFalse(sp.IsNull, "#D04");
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(sp.Parent)).ToInt32(), "#D05");
            Assert.AreEqual(((IntPtr)a).ToInt32(), ((IntPtr)(sp.Allocator)).ToInt32(), "#D06");

            a.Owner = p;
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(a.Owner)).ToInt32(), "#D07");

            sp.Destroy();
            Assert.IsTrue(sp.IsNull, "#D08");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#D09");
        }
コード例 #3
0
        public void AllocCriticalSize()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#C01");

            AprMemNode m = AllocHelper(a, 256, "#C02");

            a.Free(m);

            AprMemNode m1 = AllocHelper(a, 512, "#C03");
            AprMemNode m2 = AllocHelper(a, 1024, "#C04");

            a.Free(m2);

            AprMemNode m3 = AllocHelper(a, 2048, "#C05");
            AprMemNode m4 = AllocHelper(a, 4096, "#C06");
            AprMemNode m5 = AllocHelper(a, 6148, "#C07");

            a.Free(m5);

            a.Free(m3);
            a.Free(m1);
            a.Free(m4);

            m1 = AllocHelper(a, 9216, "#D02");
            m2 = AllocHelper(a, 12265, "#D03");
            m3 = AllocHelper(a, 16384, "#D04");
            a.Free(m2);
            a.Free(m3);
            a.Free(m1);

            a.Destroy();
            Assert.IsTrue(a.IsNull, "#C08");
        }
コード例 #4
0
        public void AllocLoopMaxFree()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#E000001");
            a.MaxFree = 81920;

            int        adrChange = 0;
            int        currAdr   = 0;
            int        lastAdr   = 0;
            AprMemNode m;

            for (int i = 24; i < (4096 * 512); i += 24)
            {
                m       = AllocHelper(a, i, String.Format("#E{0,6}", i + 3));
                currAdr = ((IntPtr)m).ToInt32();
                if (lastAdr != currAdr)
                {
                    lastAdr = currAdr;
                    adrChange++;
                }
                a.Free(m);
            }
            Assert.AreEqual(25, adrChange, 25, "#D000002");          // Normaly less than 10

            a.Destroy();
            Assert.IsTrue(a.IsNull, "#E000003");
        }
コード例 #5
0
        // Sorry, but for now, we call apr directly and do not support
        // actuel svn wrappers around apr pool

        public static AprAllocator AllocatorCreate()
        {
            AprAllocator allocator = AprAllocator.Create();

            //SVN_ALLOCATOR_RECOMMENDED_MAX_FREE = 4Mb
            allocator.MaxFree = (4096 * 1024);

            return(allocator);
        }
コード例 #6
0
        public void CreateDestroy()
        {
            AprAllocator a = new AprAllocator();

            Assert.IsTrue(a.IsNull, "#A01");

            a = AprAllocator.Create();
            Assert.IsFalse(a.IsNull, "#A02");

            a.Destroy();
            Assert.IsTrue(a.IsNull, "#A03");
        }
コード例 #7
0
        public void AllocSimple()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#B01");

            AprMemNode m = AllocHelper(a, 256, "#B02");

            a.Free(m);

            a.Destroy();
            Assert.IsTrue(a.IsNull, "#B03");
        }
コード例 #8
0
        public void CreateDestroyWithCustomAllocator()
        {
            AprAllocator a = AprAllocator.Create();

            Assert.IsFalse(a.IsNull, "#C01");

            AprPool p = AprPool.Create(a);

            Assert.IsFalse(p.IsNull, "#C02");
            Assert.AreEqual(((IntPtr)a).ToInt32(), ((IntPtr)(p.Allocator)).ToInt32(), "#C03");

            a.Owner = p;
            Assert.AreEqual(((IntPtr)p).ToInt32(), ((IntPtr)(a.Owner)).ToInt32(), "#C04");

            p.Destroy();
            Assert.IsTrue(p.IsNull, "#C05");
        }