public void AddTask(DocumentTask dt) { lock (queueLock) { work.Enqueue(delegate() { bool wasAdded = false; bool isBuildTask = dt.IsBuildTask; try { ThrowIfDisposed(); if (isBuildTask) { TaskInfo buildTI = GetBuildTaskInfo(dt.Document); if (!buildTI.Contains(dt)) { buildTI.Add(dt); wasAdded = true; } } else { TaskInfo backgroundTI = GetBackgroundTaskInfo(dt.Document); if (!backgroundTI.Contains(dt)) { backgroundTI.Add(dt); wasAdded = true; } } } finally { if (!wasAdded) { dt.Dispose(); } } }); } }
public void Remove(DocumentTask dt) { if (this.taskSet.Contains(dt)) { this.taskSet.Remove(dt); this.deadSet.Add(dt); this.cachedList = null; } }
private DocumentTask[] GetAllTasks() { HashSet <DocumentTask> addedTasks = new HashSet <DocumentTask>(); DocumentTask[] allBackgroundTasks = this.GetBackgroundTasks(); DocumentTask[] allBuildTasks = this.GetBuildTasks(); DocumentTask[] allTasks = new DocumentTask[allBackgroundTasks.GetLength(0) + allBuildTasks.GetLength(0)]; allBackgroundTasks.CopyTo(allTasks, 0); allBuildTasks.CopyTo(allTasks, allBackgroundTasks.GetLength(0)); return(allTasks); }
public void Add(DocumentTask dt) { if (!this.taskSet.Contains(dt)) { this.taskSet.Add(dt); } if (this.deadSet.Contains(dt)) { this.deadSet.Remove(dt); } else { this.taskList.AddLast(dt); } this.cachedList = null; }
public DocumentTask[] GetBackgroundTasks() { // This method is called only from unit tests or from // other synchronized TaskReporter methods, and thus // does not require synchronization LinkedList <DocumentTask> allBackgroundTasks = new LinkedList <DocumentTask>(); foreach (TaskInfo ti in backgroundTasks) { LinkedList <DocumentTask> bts = ti.TaskList; // TODO: Again, should really be able to concatenate here foreach (DocumentTask dt in bts) { allBackgroundTasks.AddLast(dt); } } DocumentTask[] dta = new DocumentTask[allBackgroundTasks.Count]; allBackgroundTasks.CopyTo(dta, 0); return(dta); }
public DocumentTask[] GetBuildTasks() { // This method is called only from unit tests or from // other synchronized TaskReporter methods, and thus // does not require synchronization LinkedList <DocumentTask> allBuildTasks = new LinkedList <DocumentTask>(); // TODO: Should be able to concatenate the lists here foreach (TaskInfo ti in buildTasks) { LinkedList <DocumentTask> bts = ti.TaskList; foreach (DocumentTask dt in bts) { allBuildTasks.AddLast(dt); } } // TODO: Maybe we should just return linked lists DocumentTask[] dta = new DocumentTask[allBuildTasks.Count]; allBuildTasks.CopyTo(dta, 0); return(dta); }
public bool Contains(DocumentTask dt) { return(this.taskSet.Contains(dt) && !this.deadSet.Contains(dt)); }