public DataStore(List <IListElement <T> > listElements, RCQMode rcqMode, string traceType) { this.queueMode = rcqMode; this.traceType = traceType; this.dequeuerQueue = new ConcurrentQueue <TaskCompletionSource <ConditionalValue <IListElement <T> > > >(); this.dequeuersState = DequeuerState.None; this.LinkedCount = 0; this.updateLatch = new object(); this.ListElements = new ConcurrentDictionary <long, ListElement>(); this.head = null; this.tail = null; // descending order listElements.Sort((a, b) => b.Id.CompareTo(a.Id)); foreach (var listElement in listElements) { this.AddListElement(listElement); this.AssertUnlinked(listElement); this.LinkHeadUnsafe(listElement); } }
public static async Task <DataStore <T> > ReadCopyFileAsync <T>(string directory, IStateSerializer <T> valueSerializer, RCQMode queueMode, string traceType) { var copy = new Checkpoint <T>(directory, CopyFileName, valueSerializer, traceType); await copy.ReadAsync().ConfigureAwait(false); // do not ReleaseRef on the copy file; it will be deleted later. Keeping the file around may enable // a DR scenario where the primary copies the last copy of its state to a secondary and is then lost, // and the new secondary crashes in between deleting the copy file and making the copied state the new // checkpoint. return(new DataStore <T>(copy.ListElements, queueMode, traceType)); }
public DataStore(RCQMode rcqMode, string traceType) : this(new List <IListElement <T> >(), rcqMode, traceType) { }