Example #1
0
            public BaseClousotWorker(IWorkerId id, FList <string> baseArgs, IScheduler scheduler)
                : base(id, scheduler)
            {
                Contract.Requires(id != null);

                this.baseArgs = baseArgs;
            }
Example #2
0
        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();
                }
            }
        }
Example #3
0
        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);
            }
        }
Example #4
0
            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;
            }
Example #5
0
        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();
        }
Example #6
0
    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();
    }
Example #7
0
    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);
    }
Example #8
0
        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);
        }
Example #9
0
    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;
    }
Example #10
0
        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);
        }
Example #11
0
 protected virtual bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId)
 {
     return(false);
 }
Example #12
0
 public bool TryPop(IWorkerId workerId, out IWorkId workId)
 {
   return this.queue.TryPop(workerId, out workId);
 }
Example #13
0
            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;
            }
Example #14
0
 protected override bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId)
 {
     return(this.workerPool.CancelWork(workerId));
 }
Example #15
0
        public override void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode)
        {
            base.ReportDone(workerId, workId, returnCode);

            this.FeedQueue(this.SlicesToScheduleForReanalysis(workId));
        }
Example #16
0
 public abstract Worker NewWorker(IWorkerId workerId);
Example #17
0
 public bool TryPop(IWorkerId workerId, out IWorkId workId)
 {
     return(this.queue.TryPop(workerId, out workId));
 }
Example #18
0
    public override void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode)
    {
      base.ReportDone(workerId, workId, returnCode);

      this.FeedQueue(this.SlicesToScheduleForReanalysis(workId));
    }
Example #19
0
 public override Worker NewWorker(IWorkerId workerId)
 {
     return(new ClousotWorker(this.CallClousotMain, workerId, this.args, this.scheduler, output, this.db));
 }