public void Dispose() { Finished = true; Ahead.Dispose(); if (TIsDisposable) { foreach (var item in Content) { ((IDisposable)item).Dispose(); } } }
public void Write(T item) { if (Finished) { return; } Ahead.WaitOne(); lock (Lock) { if (Content[Modulo(TotalWritten, Size)] != null && TIsDisposable) { ((IDisposable)Content[Modulo(TotalWritten, Size)]).Dispose(); } Content[Modulo(TotalWritten++, Size)] = item; } }
public T Read() { if (Finished && !HasFront) { return(default(T)); } lock (Lock) { if (DejaVu > 0) { --DejaVu; } else if (!Finished) { Ahead.Release(); } // Ahead.Release(); return(Content[Modulo(ReadIndex++, Size)]); } }
public override int GetHashCode() { if (hashcode.HasValue) { return(hashcode.Value); } unchecked { hashcode = (int)2166136261; hashcode = hashcode * 1677619 + (LocalBranch?.GetHashCode() ?? 0); hashcode = hashcode * 1677619 + (RemoteBranch?.GetHashCode() ?? 0); hashcode = hashcode * 1677619 + Ahead.GetHashCode(); hashcode = hashcode * 1677619 + Behind.GetHashCode(); foreach (var entry in Entries) { hashcode = hashcode * 1677619 + entry.GetHashCode(); } return(hashcode.Value); } }