/// <summary> /// Cancels all work items in the queue. /// Note that items which have been taken off the queue and are running /// or about to be started cannot be cancelled. /// </summary> public void CancelAllWorkItems() { lock (_queueLock) { _queue.Clear(); } }
public void Update() { if (m_bRunTest == false) { return; } m_bRunTest = false; m_raqTestQueue = new RandomAccessQueue <int>(5); //test queue //queue some random items for (int i = 0; i < m_raqTestQueue.Capacity; i++) { m_raqTestQueue.Enqueue(i); } //peek last itme Debug.Log("Peak Item " + m_raqTestQueue.PeakDequeue()); //print out results while (m_raqTestQueue.Count > 0) { Debug.Log("Dequeued Item " + m_raqTestQueue.Dequeue()); } //test random access //queue some random items for (int i = 0; i < m_raqTestQueue.Capacity; i++) { m_raqTestQueue.Enqueue(i); } for (int i = 0; i < m_raqTestQueue.Count; i++) { Debug.Log("Random Access Item " + m_raqTestQueue[i]); } //test clear m_raqTestQueue.Clear(); //test queue expansion for (int i = 0; i < 20; i++) { m_raqTestQueue.Enqueue(i); } for (int i = 0; i < m_raqTestQueue.Count; i++) { Debug.Log("Random Access Item " + m_raqTestQueue[i]); } }
private void SendPackets() { //check if there is anything to send if (m_PacketsInFlight.Count == 0) { return; } //calculate the number of packets that dont need to be sent int iPacketsToDrop = m_PacketsInFlight.Count - (m_iPacketsQueuedToSendCount - m_iLastAckPacketNumberSent); if (iPacketsToDrop >= m_PacketsInFlight.Count) { m_PacketsInFlight.Clear(); return; } //dequeue all the old packets that have already been acknowledged for (int i = 0; i < iPacketsToDrop; i++) { m_PacketsInFlight.Dequeue(); } if (m_PacketsInFlight.Count == 0) { return; } //create packet wrapper PacketWrapper pkwPacketWrappepr = new PacketWrapper(m_iTotalPacketsReceived, m_iPacketsQueuedToSendCount - m_PacketsInFlight.Count, m_PacketsInFlight.Count); //add as many packets as possible without hitting the max send data limit for (int i = 0; i < m_PacketsInFlight.Count; i++) { pkwPacketWrappepr.AddDataPacket(m_PacketsInFlight[i]); } //send packet through coms if (m_icsConnectionSim != null) { m_icsConnectionSim.SendPacket(pkwPacketWrappepr, m_conConnectionTarget); } }