/// <summary> /// Dequeue a set of records. /// </summary> /// <param name="buffers">Will be cleared and then filled with all available buffers</param> /// <param name="maxAmountOfMessages">Number of wanted records (will return less if less are available)</param> public void Dequeue(List <byte[]> buffers, int maxAmountOfMessages) { if (buffers == null) { throw new ArgumentNullException("buffers"); } var initialSize = buffers.Count; var count1 = _readFile.Dequeue(buffers, maxAmountOfMessages); if (buffers.Any()) { Interlocked.Add(ref _count, 0 - count1); return; } if (!TryOpenNextReadFile()) { return; } var leftToEnqueue = maxAmountOfMessages - (buffers.Count - initialSize); var count2 = _readFile.Dequeue(buffers, leftToEnqueue); Interlocked.Add(ref _count, 0 - (count1 + count2)); }
/// <summary> /// Dequeue a set of records. /// </summary> /// <param name="buffers">Will be cleared and then filled with all available buffers</param> /// <param name="maxAmountOfMessages">Number of wanted records (will return less if less are available)</param> public void Dequeue(List <byte[]> buffers, int maxAmountOfMessages) { if (buffers == null) { throw new ArgumentNullException("buffers"); } buffers.Clear(); _readFile.Dequeue(buffers, maxAmountOfMessages); if (buffers.Any()) { return; } if (!TryOpenNextReadFile()) { return; } _readFile.Dequeue(buffers, maxAmountOfMessages); }