public BaseClousotWorker(IWorkerId id, FList <string> baseArgs, IScheduler scheduler) : base(id, scheduler) { Contract.Requires(id != null); this.baseArgs = baseArgs; }
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 ClousotWorker(CallAnyClousotMainFunc callClousotMain, IWorkerId id, FList <string> baseArgs, IScheduler scheduler, ISimpleLineWriter output) : base(id, baseArgs, scheduler) { Contract.Requires(id != null); this.callClousotMain = callClousotMain; this.output = output; }
private ManualResetEvent idle = new ManualResetEvent(false); // To notify I am idle public Worker(IWorkerId id, IScheduler scheduler) { Contract.Requires(id != null); this.id = id; this.scheduler = scheduler; this.thread = CreateThread(); }
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); }
public bool CancelWork(IWorkerId workerId) { if (!this.canCancel) return false; Worker worker; if (!this.workers.TryGetValue(workerId, out worker)) return false; worker.Cancel(); worker.Start(); return true; }
public bool CancelWork(IWorkerId workerId) { if (!this.canCancel) { return(false); } Worker worker; if (!this.workers.TryGetValue(workerId, out worker)) { return(false); } worker.Cancel(); worker.Start(); return(true); }
protected virtual bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId) { return(false); }
public bool TryPop(IWorkerId workerId, out IWorkId workId) { return this.queue.TryPop(workerId, out workId); }
public ClousotWorker(CallLocalClousotMainFunc <Method, Assembly> callClousotMain, IWorkerId id, FList <string> baseArgs, IScheduler scheduler, ISimpleLineWriter output, IDB db) : base(id, baseArgs, scheduler) { Contract.Requires(id != null); this.callClousotMain = callClousotMain; this.output = output; this.db = db; }
protected override bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId) { return(this.workerPool.CancelWork(workerId)); }
public override void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode) { base.ReportDone(workerId, workId, returnCode); this.FeedQueue(this.SlicesToScheduleForReanalysis(workId)); }
public abstract Worker NewWorker(IWorkerId workerId);
public bool TryPop(IWorkerId workerId, out IWorkId workId) { return(this.queue.TryPop(workerId, out workId)); }
public override Worker NewWorker(IWorkerId workerId) { return(new ClousotWorker(this.CallClousotMain, workerId, this.args, this.scheduler, output, this.db)); }