public void Enqueue(T[] items, int offset, int length) { items.ValidateParameters(offset, length); while (true) { //If the header is empty. Get a new one. if (m_currentHead == null || !m_currentHead.CanEnqueue) { m_currentHead = GetNode(); m_currentHead.Reset(); Thread.MemoryBarrier(); m_blocks.Enqueue(m_currentHead); m_enqueueCount++; } //If the remainder will fit, queue it all. int enqueueLength = m_currentHead.AvailableEnqueueLength; if (length <= enqueueLength) { m_currentHead.Enqueue(items, offset, length); m_enqueueCount += length; return; } //Some will not fit. Enqueue what will fit, then repeat. m_currentHead.Enqueue(items, offset, enqueueLength); m_enqueueCount += enqueueLength; offset += enqueueLength; length -= enqueueLength; } }
public void Enqueue(T item) { if (m_currentHead != null && m_currentHead.CanEnqueue) { m_currentHead.Enqueue(item); m_enqueueCount++; return; } EnqueueSlower(item); }