internal WorkBatch(WorkBatchCollection workBackCollection) { this.mutex = new object(); this._pendingWorkCollection = new PendingWorkCollection(); this._state = WorkBatchState.Usable; this._collection = workBackCollection; }
/// <summary> /// API for Runtime to call to do Merge Operation: Right now /// we dont use this because we dont support incoming work collection. /// </summary> /// <param name="batch"></param> internal void Merge(WorkBatch batch) { if (batch == null) { return; //nothing to merge } if (_pendingWorkCollection == null) { throw new ObjectDisposedException("WorkBatch"); } lock (this.mutex) { lock (batch.mutex) { foreach (KeyValuePair <IPendingWork, SortedList <long, object> > item in batch._pendingWorkCollection.WorkItems) { //_pendingWorkCollection.AddRange(item.Key, item.Value); SortedList <long, object> newItems = item.Value; foreach (KeyValuePair <long, object> kvp in newItems) { _pendingWorkCollection.Add(item.Key, kvp.Key, kvp.Value); } } } this._state = WorkBatchState.Merged; } }
internal void Complete(bool succeeded) { lock (this.mutex) { if (this._pendingWorkCollection.IsUsable) { this._pendingWorkCollection.Complete(succeeded); this._pendingWorkCollection.Dispose(); this._state = WorkBatchState.Completed; } } }
internal void Merge(WorkBatch batch) { if (batch != null) { if (this._pendingWorkCollection == null) { throw new ObjectDisposedException("WorkBatch"); } lock (this.mutex) { lock (batch.mutex) { foreach (KeyValuePair <IPendingWork, SortedList <long, object> > pair in batch._pendingWorkCollection.WorkItems) { foreach (KeyValuePair <long, object> pair2 in pair.Value) { this._pendingWorkCollection.Add(pair.Key, pair2.Key, pair2.Value); } } } this._state = WorkBatchState.Merged; } } }
internal void Merge(WorkBatch batch) { if (batch != null) { if (this._pendingWorkCollection == null) { throw new ObjectDisposedException("WorkBatch"); } lock (this.mutex) { lock (batch.mutex) { foreach (KeyValuePair<IPendingWork, SortedList<long, object>> pair in batch._pendingWorkCollection.WorkItems) { foreach (KeyValuePair<long, object> pair2 in pair.Value) { this._pendingWorkCollection.Add(pair.Key, pair2.Key, pair2.Value); } } } this._state = WorkBatchState.Merged; } } }
internal WorkBatch(WorkBatchCollection workBackCollection) { _pendingWorkCollection = new PendingWorkCollection(); _state = WorkBatchState.Usable; _collection = workBackCollection; }