jobList.hpp 806 B

12345678910111213141516171819202122232425262728293031323334353637
  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 waitOne(microseconds us);
  13. void finishJob();
  14. void setDoneCallback(DoneCallback cb);
  15. size_t getPendingJobCount() const {return pendingJobCount;}
  16. std::shared_ptr<Job>& getJob(size_t i);
  17. std::shared_ptr<Job>& getNextJob();
  18. size_t getJobCount() const {return jobCount;}
  19. private:
  20. std::vector<std::shared_ptr<Job>> jobs;
  21. DoneCallback doneCb;
  22. size_t jobCount;
  23. size_t pendingJobCount;
  24. std::condition_variable jobListDone;
  25. std::mutex pendingJobCount_m;
  26. size_t nextJobIndex = 0;
  27. };
  28. #endif