jobList.hpp 720 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef myJOBLIST_H
  2. #define myJOBLIST_H
  3. #include <functional>
  4. #include <vector>
  5. #include "job.hpp"
  6. #include "modules.hpp"
  7. //entity to track an array of similar jobs
  8. class JobList {
  9. public:
  10. JobList(Module mod, size_t numberOfJobs);
  11. void waitAll();
  12. void finishJob();
  13. void setDoneCallback(DoneCallback cb);
  14. size_t getPendingJobCount() const {return pendingJobCount;}
  15. std::shared_ptr<Job>& getJob(size_t i);
  16. std::shared_ptr<Job> getNextJob();
  17. private:
  18. std::vector<std::shared_ptr<Job>> jobs;
  19. DoneCallback doneCb;
  20. size_t jobCount;
  21. size_t pendingJobCount;
  22. std::condition_variable jobListDone;
  23. std::mutex pendingJobCount_m;
  24. size_t nextJobIndex = 0;
  25. };
  26. #endif