public Event[] DequeueBunch() { LogBuffer buf = _first; if (buf.Empty) { if (buf.Done) { var oldFirst = _first; var next = oldFirst.Next; if (next != null) { Interlocked.CompareExchange(ref _first, next, oldFirst); } } return(null); } var res = buf.PopCurrent(); if (buf.Done && buf.Empty) { var oldFirst1 = _first; var next1 = oldFirst1.Next; if (next1 != null) { Interlocked.CompareExchange(ref _first, next1, oldFirst1); } } if ((res.Offset == 0) && (res.Count == res.Array.Length)) { return(res.Array); } Event[] res2 = new Event[res.Count]; Array.Copy(res.Array, res.Offset, res2, 0, res.Count); return(res2); }
public int DequeueBunch(ref Event[] into) { LogBuffer buf = _first; if (buf.Empty) { if (buf.Done) { var oldFirst = _first; var next = oldFirst.Next; if (next != null) { Interlocked.CompareExchange(ref _first, next, oldFirst); } } return(0); } var res = buf.PopCurrent(); if (buf.Done && buf.Empty) { var oldFirst1 = _first; var next1 = oldFirst1.Next; if (next1 != null) { Interlocked.CompareExchange(ref _first, next1, oldFirst1); } } if (res.Count != into.Length) { Array.Resize(ref into, res.Count); } Array.Copy(res.Array, res.Offset, into, 0, res.Count); return(res.Count); }