public void ReportDone(IWorkerId workerId, IWorkId workId) { lock (this.Lock) { // This loop is not sound as we are not monotonic foreach (var p in this.WorkInProgress.GetValueOrEmpty(workId.SliceId).AssumeNotNull().Where(p => p.Key.Time < workId.Time).ToArray()) { if (this.CancelWork(p.Key, p.Value)) { this.WorkInProgress.Remove(p.Key); } } this.WorkInProgress.Remove(workId.SliceId, workId.SliceHash); } this.MarkAsComputed(workId.SliceId, workId.SliceHash); // Maybe not used, see if we can remove it if (this.OnWorkDone != null) { this.OnWorkDone(workerId, workId); } lock (this.Lock) { // If the queue is empty, let's trigger the event if (this.InternalIsEmpty()) { this.EmptyQueue.Set(); } } }
public bool TryPop(IWorkerId workerId, out IWorkId workId) { lock (this.Lock) { if (this.ToDo.Count == 0) { workId = default(IWorkId); return(false); } var workToDo = this.ToDo.Pop(); Contract.Assume(workToDo != null); // Untested option if (this.optionB2) { foreach (var p in this.WorkInProgress.GetValueOrEmpty(workToDo.SliceId).AssumeNotNull()) { this.CancelWork(p.Key, p.Value); } } // Untested option if (this.optionA2) { this.WorkInProgress.Remove(workToDo.SliceId); } this.WorkInProgress.Add(workToDo, workerId); workId = workToDo; return(true); } }
public virtual void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode) { // TODO: what to do with errors? -- the time being we let OnWorkDone record them if (this.OnWorkDone != null) { this.OnWorkDone(workId.SliceId, returnCode); } this.queue.ReportDone(workerId, workId); }
protected override FList <string> MakeArgs(IWorkId work) { var args = base.MakeArgs(work); if (this.db != null) { args = args.Cons("-cache"); } return(args); }
protected virtual FList <string> MakeArgs(IWorkId work) { Contract.Requires(work != null); var args = this.baseArgs; args = args.Cons(work.SliceId.Dll); // the dll to analyze args = args.Cons("-sliceTime:" + work.Time.ToBinary()); // The sliceTime is the "universal" time -- to see: can we replace it with a job id? return(args); }
protected override int Do(IWorkId work) { var args = this.MakeArgs(work).ToArray(); var bufferedOutput = BufferedTextWriter.Create(); try { bufferedOutput.WriteLine("Analysis of dll: {0}", work.SliceId.Dll); return(this.callClousotMain(args, bufferedOutput)); } finally { this.output.WriteLine(bufferedOutput.ToString()); } }
protected override int Do(IWorkId work) { var args = this.MakeArgs(work).ToArray(); var bufferedOutput = BufferedTextWriter.Create(); try { var outputFactory = new FullTextWriterOutputFactory <Method, Assembly>(bufferedOutput); this.output.WriteLine("[SlicerWorker: {0}] Analysis of dll (Time stamp {1}) {2}", DateTime.Now, work.Time, work.SliceId.Dll); return(this.callClousotMain(args, outputFactory, this.db.AsEnumerable())); } finally { this.output.WriteLine(bufferedOutput.ToString()); } }
protected override IEnumerable <ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { return(this.db.Dependences(workId.SliceId)); }
public override void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode) { base.ReportDone(workerId, workId, returnCode); this.FeedQueue(this.SlicesToScheduleForReanalysis(workId)); }
protected virtual IEnumerable <ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { yield break; }
public bool TryPop(IWorkerId workerId, out IWorkId workId) { return(this.queue.TryPop(workerId, out workId)); }
protected override IEnumerable <ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { return(base.SlicesToScheduleForReanalysis(workId).Union(this.db.SlicesForMethodsInTheSameType(workId.SliceId)).Distinct()); }
public bool Equals(IWorkId other) { return(other != null && this.sliceId.Equals(other.SliceId) && this.time.Equals(other.Time) && this.sliceHash.Equals(other.SliceHash)); }
private void OnWorkDone(IWorkId work, int returnCode) { this.scheduler.ReportDone(this.id, work, returnCode); }
protected abstract int Do(IWorkId work);
private bool TryGetWorkToDo(out IWorkId workId) { return(this.scheduler.TryPop(this.id, out workId)); }
public bool TryPop(IWorkerId workerId, out IWorkId workId) { return this.queue.TryPop(workerId, out workId); }
protected override IEnumerable<ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { return base.SlicesToScheduleForReanalysis(workId).Union(this.db.SlicesForMethodsInTheSameType(workId.SliceId)).Distinct(); }
protected virtual IEnumerable<ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { yield break; }
private bool TryGetWorkToDo(out IWorkId workId) { return this.scheduler.TryPop(this.id, out workId); }
protected override IEnumerable<ISliceId> SlicesToScheduleForReanalysis(IWorkId workId) { return this.db.Dependences(workId.SliceId); }