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

                this.baseArgs = baseArgs;
            }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
            }
Exemplo n.º 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();
        }
Exemplo n.º 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();
    }
Exemplo n.º 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);
    }
Exemplo n.º 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);
        }
Exemplo n.º 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;
    }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
 protected virtual bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId)
 {
     return(false);
 }
Exemplo n.º 12
0
 public bool TryPop(IWorkerId workerId, out IWorkId workId)
 {
   return this.queue.TryPop(workerId, out workId);
 }
Exemplo n.º 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;
            }
Exemplo n.º 14
0
 protected override bool CancelWork(WorkToDo <TPriority> work, IWorkerId workerId)
 {
     return(this.workerPool.CancelWork(workerId));
 }
Exemplo n.º 15
0
        public override void ReportDone(IWorkerId workerId, IWorkId workId, int returnCode)
        {
            base.ReportDone(workerId, workId, returnCode);

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

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