//--------------------------------------------------------------------- // ILillTekChannelManager overrides /// <summary> /// Called by LillTek channels accepted by this listener when the /// channel is closed or aborted to terminate any pending operations. /// </summary> /// <param name="channel">The closed or aborted channel.</param> /// <param name="e">The exception to be used to terminate the operation.</param> public override void OnChannelCloseOrAbort(LillTekChannelBase channel, Exception e) { using (TimedLock.Lock(this)) { // Abort any pending operations related to the channel. if (waitQueue != null) { for (int i = waitQueue.Count - 1; i >= 0; i--) { Assertion.Test(waitQueue[i].InternalState != null, "InternalState should have been set to the channel."); if (waitQueue[i].InternalState == channel) { waitQueue[i].Notify(); waitQueue.RemoveAt(i); } } } if (receiveQueue != null) { for (int i = receiveQueue.Count - 1; i >= 0; i--) { Assertion.Test(receiveQueue[i].InternalState != null, "InternalState should have been set to the channel."); if (receiveQueue[i].InternalState == channel) { receiveQueue[i].Notify(); receiveQueue.RemoveAt(i); } } } } base.OnChannelCloseOrAbort(channel, e); }
public void QueueArray_RemoveAt() { QueueArray <int> queue = new QueueArray <int>(); queue.Enqueue(0); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); queue.RemoveAt(0); CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4, 5 }, queue.ToArray()); queue.RemoveAt(queue.Count - 1); CollectionAssert.AreEqual(new int[] { 1, 2, 3, 4 }, queue.ToArray()); queue.RemoveAt(2); CollectionAssert.AreEqual(new int[] { 1, 2, 4 }, queue.ToArray()); }