Пример #1
0
        /// <summary>
        /// Stops dispatching the work items and clears the work item queue.
        /// Doesn't wait for the work threads to stop.
        /// </summary>
        public void Stop()
        {
            m_shutdown = true;
            lock (m_queue)
            {
                Monitor.PulseAll(m_queue);
            }

            m_queue.Clear();
        }
Пример #2
0
        public void ZeroLimitMeansUnlimitedSize()
        {
            var q = new LimitedSizeQueue <int>(0);

            foreach (var item in Enumerable.Range(1, 1000))
            {
                Assert.IsTrue(q.TryEnqueue(item));
            }

            q.Clear();
            Assert.AreEqual(0, q.Count);
            Assert.AreEqual(0, q.Limit);
        }
Пример #3
0
        public void LimitedSizeQueueCanClearItems()
        {
            var q = new LimitedSizeQueue <int>(3);

            Assert.IsTrue(q.TryEnqueue(1));
            Assert.IsTrue(q.TryEnqueue(2));
            Assert.IsTrue(q.TryEnqueue(3));
            Assert.IsFalse(q.TryEnqueue(4));

            Assert.AreEqual(3, q.Count);
            Assert.AreEqual(3, q.Limit);

            q.Clear();
            Assert.AreEqual(0, q.Count);
            Assert.AreEqual(3, q.Limit);

            var items = string.Join(", ", q.Select(i => i.ToString()).ToArray());

            Assert.AreEqual(string.Empty, items);
        }
Пример #4
0
 public ICollider GoBackInTime()
 {
     Position = pastPosition.Last;
     pastPosition.Clear();
     return(this);
 }