Пример #1
0
        public void New_TryDequeue_TryEnqueue_x50_TryDequeue_x50_TryDequeue_Count()
        {
            int value;
            var q = new LockFreeQueue <int>();

            Assert.AreEqual(0, q.Count);

            q.TryDequeue(out value);
            Assert.AreEqual(0, q.Count);

            for (int i = 0; i < 50; ++i)
            {
                q.TryEnqueue(100 - i);
            }
            Assert.AreEqual(50, q.Count);

            for (int i = 0; i < 50; ++i)
            {
                q.TryDequeue(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

            q.TryDequeue(out value);
            Assert.AreEqual(0, q.Count);
        }
Пример #2
0
        public void New_TryEnqueue_Count()
        {
            var q = new LockFreeQueue <int>();

            Assert.AreEqual(0, q.Count);

            q.TryEnqueue(42);
            Assert.AreEqual(1, q.Count);
        }
Пример #3
0
        public void New_TryDequeue_TryEnqueue_Count()
        {
            int value;
            var q = new LockFreeQueue<int>();
            Assert.AreEqual(0, q.Count);

            q.TryDequeue(out value);
            Assert.AreEqual(0, q.Count);

            q.TryEnqueue(42);
            Assert.AreEqual(1, q.Count);
        }
Пример #4
0
        public void New_TryEnqueue_TryDequeue_Count()
        {
            int value;
            var q = new LockFreeQueue <int>();

            Assert.AreEqual(0, q.Count);

            q.TryEnqueue(42);
            Assert.AreEqual(1, q.Count);

            q.TryDequeue(out value);
            Assert.AreEqual(42, value);
            Assert.AreEqual(0, q.Count);
        }
Пример #5
0
        public void New_TryEnqueue_x50_TryDequeue_x50_TryDequeue_Count()
        {
            int value;
            var q = new LockFreeQueue<int>();
            Assert.AreEqual(0, q.Count);

            for(int i = 0; i < 50; ++i) {
                q.TryEnqueue(100 - i);
            }
            Assert.AreEqual(50, q.Count);

            for(int i = 0; i < 50; ++i) {
                q.TryDequeue(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

            q.TryDequeue(out value);
            Assert.AreEqual(0, q.Count);
        }