/// <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(); }
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); }
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); }
public ICollider GoBackInTime() { Position = pastPosition.Last; pastPosition.Clear(); return(this); }