public bool MoveNext() { if (currentQueuePosition == sharedState.currentEnumeratedObjectListSize) { lock (sharedState.syncObject) { //double check instead the size was changed between the while and the lock while (currentQueuePosition == sharedState.currentEnumeratedObjectListSize) { //Check for any exception thrown by the task executers if (sharedState.exceptionOccured != null) { throw sharedState.exceptionOccured; } //If all enumerators are done or enumerator is disposed return false if (sharedState.allEnumeratorsDone || sharedState.disposed) { return(false); } //If not done creating the list block until the list status has changed else { Monitor.Wait(sharedState.syncObject); } } } } currentPositionNode = currentPositionNode.Next; currentQueuePosition++; return(true); }
public LinkableLinkedListBlockingEnumerator(EnumerateTaskSharedState sharedState) { this.sharedState = sharedState; while (currentPositionNode == null) { lock (sharedState.syncObject) { //Check for any exception thrown by the task executers if (sharedState.exceptionOccured != null) { throw sharedState.exceptionOccured; } //Create first node when the accumulated list has elements if (sharedState.accumulatedEnumeratedObjectList.First != null) { currentPositionNode = new LinkableLinkedListNode(null); currentPositionNode.Next = sharedState.accumulatedEnumeratedObjectList.First; } //If all enumerators are done or enumerator is disposed, break else if (sharedState.allEnumeratorsDone || sharedState.disposed) { break; } //If there are no elements in the list yet block until status changed else { Monitor.Wait(sharedState.syncObject); } } } }
public void AppendValue(object value) { //Empty list if (_first == null) { _first = new LinkableLinkedListNode(value); _last = _first; _count = 1; } else { _last.Next = new LinkableLinkedListNode(value); _last = _last.Next; _count++; } }
public void AppentList(LinkableLinkedList list) { //Empty list if (_first == null) { _first = list.First; _last = list.Last; _count = list.Count; } else { _last.Next = list.First; //If the given list to append is empty if (list.Last != null) _last = list.Last; _count += list.Count; } }
public void AppentList(LinkableLinkedList list) { //Empty list if (_first == null) { _first = list.First; _last = list.Last; _count = list.Count; } else { _last.Next = list.First; //If the given list to append is empty if (list.Last != null) { _last = list.Last; } _count += list.Count; } }
public LinkableLinkedListBlockingEnumerator(EnumerateTaskSharedState sharedState) { this.sharedState = sharedState; while (currentPositionNode == null) lock (sharedState.syncObject) { //Check for any exception thrown by the task executers if (sharedState.exceptionOccured != null) throw sharedState.exceptionOccured; //Create first node when the accumulated list has elements if (sharedState.accumulatedEnumeratedObjectList.First != null) { currentPositionNode = new LinkableLinkedListNode(null); currentPositionNode.Next = sharedState.accumulatedEnumeratedObjectList.First; } //If all enumerators are done or enumerator is disposed, break else if (sharedState.allEnumeratorsDone || sharedState.disposed) break; //If there are no elements in the list yet block until status changed else Monitor.Wait(sharedState.syncObject); } }
public bool MoveNext() { if(currentQueuePosition == sharedState.currentEnumeratedObjectListSize) { lock(sharedState.syncObject) { //double check instead the size was changed between the while and the lock while (currentQueuePosition == sharedState.currentEnumeratedObjectListSize) { //Check for any exception thrown by the task executers if (sharedState.exceptionOccured != null) throw sharedState.exceptionOccured; //If all enumerators are done or enumerator is disposed return false if (sharedState.allEnumeratorsDone || sharedState.disposed) return false; //If not done creating the list block until the list status has changed else Monitor.Wait(sharedState.syncObject); } } } currentPositionNode = currentPositionNode.Next; currentQueuePosition++; return true; }