/// <summary> /// When an activity gets executed and needs to be finalized, all activity objects that have /// the same id need to be finalized too. The Attach methods puts all activities with the /// same id to a chain to let the Finish method call the Finish method of each object in the chain. /// This method was needed because it is possible that the same activity arrives from different /// sources: e.g from messaging, from database or from direct execution. /// </summary> /// <param name="activity"></param> internal void Attach(LuceneIndexingActivity activity) { if (AttachedActivity != null) { AttachedActivity.Attach(activity); } else { AttachedActivity = activity; } }
internal void WaitFor(LuceneIndexingActivity olderActivity) { // this method must called from thread safe block. if (!this.WaitingFor.Any(x => x.Id == olderActivity.Id)) { this.WaitingFor.Add(olderActivity); } if (!olderActivity.WaitingForMe.Any(x => x.Id == this.Id)) { olderActivity.WaitingForMe.Add(this); } }
internal bool IsInTree(LuceneIndexingActivity newerActivity) { return(this.Path.StartsWith(newerActivity.Path, StringComparison.OrdinalIgnoreCase)); }
private static void RemoveDependency(List <LuceneIndexingActivity> dependencyList, LuceneIndexingActivity activity) { // this method must called from thread safe block. dependencyList.RemoveAll(x => x.Id == activity.Id); }
internal void FinishWaiting(LuceneIndexingActivity olderActivity) { // this method must called from thread safe block. RemoveDependency(this.WaitingFor, olderActivity); RemoveDependency(olderActivity.WaitingForMe, this); }