コード例 #1
0
        public void ClearTest()
        {
            var q = UnsafeMPMCQueue.Allocate <int>(16);

            //Inserts 10 items.
            SplitQueue(q);

            Assert.AreEqual(10, UnsafeMPMCQueue.GetCount(q));
            UnsafeMPMCQueue.Clear(q);
            Assert.AreEqual(0, UnsafeMPMCQueue.GetCount(q));

            Assert.IsTrue(UnsafeMPMCQueue.IsEmpty <int>(q));

            UnsafeMPMCQueue.Free(q);
        }
コード例 #2
0
        public void EnqueueTest()
        {
            var q = UnsafeMPMCQueue.Allocate <int>(100);

            for (int i = 0; i < 100; i++)
            {
                UnsafeMPMCQueue.TryEnqueue(q, i * i);
            }

            Assert.AreEqual(100, UnsafeMPMCQueue.GetCount(q));

            UnsafeMPMCQueue.Clear(q);

            Assert.AreEqual(0, UnsafeMPMCQueue.GetCount(q));

            UnsafeMPMCQueue.Free(q);
        }
コード例 #3
0
        public void ClearFixedTest()
        {
            int size = 128; // Power of two.
            var q    = UnsafeMPMCQueue.Allocate <int>(size, true);

            //Inserts 10 items.
            SplitQueue(q);

            Assert.AreEqual(10, UnsafeMPMCQueue.GetCount(q));
            Assert.AreEqual(size, UnsafeMPMCQueue.GetCapacity(q));

            UnsafeMPMCQueue.Clear(q);

            Assert.AreEqual(0, UnsafeMPMCQueue.GetCount(q));
            // Queue capacity needs to remain unchanged after clear.
            Assert.AreEqual(size, UnsafeMPMCQueue.GetCapacity(q));

            Assert.IsTrue(UnsafeMPMCQueue.IsEmpty <int>(q));

            UnsafeMPMCQueue.Free(q);
        }
コード例 #4
0
 public void Clear()
 {
     UnsafeMPMCQueue.Clear(m_inner);
 }