コード例 #1
0
        public void New_TryPop_Push_x33_TryPop_x33_TryPop_Count()
        {
            int value;
            var q = new WorkStealingDeque <int>();

            Assert.AreEqual(0, q.Count);

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

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

            for (int i = 32; i >= 0; --i)
            {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

            q.TryPop(out value);
            Assert.AreEqual(0, q.Count);
        }
コード例 #2
0
ファイル: DispatchThread.cs プロジェクト: heran/DReAM
        private void QueueWorkItem(Action callback)
        {
            // NOTE (steveb): this method MUST be called from the dispatcher's associated thread

            // increase work-item counter and enqueue item
            _inbox.Push(callback);
        }
コード例 #3
0
        public void New_TryPop_Push_x32_TryPop_x32_TryPop_Count()
        {
            object value;
            var    q = new WorkStealingDeque <object>();

            Assert.AreEqual(0, q.Count);

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

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

            for (int i = 31; i >= 0; --i)
            {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

            q.TryPop(out value);
            Assert.AreEqual(0, q.Count);
        }
コード例 #4
0
        public void New_Push_Count()
        {
            var q = new WorkStealingDeque<int>();
            Assert.AreEqual(0, q.Count);

            q.Push(42);
            Assert.AreEqual(1, q.Count);
        }
コード例 #5
0
        public void New_Push_Count()
        {
            var q = new WorkStealingDeque <int>();

            Assert.AreEqual(0, q.Count);

            q.Push(42);
            Assert.AreEqual(1, q.Count);
        }
コード例 #6
0
        public void New_Push_TryPop_Count()
        {
            int value;
            var q = new WorkStealingDeque<int>();
            Assert.AreEqual(0, q.Count);

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

            q.TryPop(out value);
            Assert.AreEqual(42, value);
            Assert.AreEqual(0, q.Count);
        }
コード例 #7
0
        public void New_TryPop_Push_Count()
        {
            int value;
            var q = new WorkStealingDeque <int>();

            Assert.AreEqual(0, q.Count);

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

            q.Push(42);
            Assert.AreEqual(1, q.Count);
        }
コード例 #8
0
        public void New_Push_x50_Count()
        {
            int value;
            var q = new WorkStealingDeque<int>();
            Assert.AreEqual(0, q.Count);

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

            for(int i = 49; i >= 0; --i) {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);
        }
コード例 #9
0
        public void New_Push_x50_TryPop_x50_Count()
        {
            int value;
            var q = new WorkStealingDeque <int>();

            Assert.AreEqual(0, q.Count);

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

            for (int i = 49; i >= 0; --i)
            {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);
        }
コード例 #10
0
        public void New_TryPop_Push_x33_TryPop_x33_TryPop_Count()
        {
            int value;
            var q = new WorkStealingDeque<int>();
            Assert.AreEqual(0, q.Count);

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

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

            for(int i = 32; i >= 0; --i) {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

            q.TryPop(out value);
            Assert.AreEqual(0, q.Count);
        }
コード例 #11
0
        public void New_TryPop_Push_x32_TryPop_x32_TryPop_Count()
        {
            object value;
            var q = new WorkStealingDeque<object>();
            Assert.AreEqual(0, q.Count);

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

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

            for(int i = 31; i >= 0; --i) {
                q.TryPop(out value);
                Assert.AreEqual(100 - i, value);
            }
            Assert.AreEqual(0, q.Count);

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