worker.hpp 657 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef myWORKER_H
  2. #define myWORKER_H
  3. #include <vector>
  4. #include <condition_variable>
  5. #include <mutex>
  6. #include <future>
  7. #include "jobList.hpp"
  8. #include "commFPGA.hpp"
  9. class Worker {
  10. public:
  11. Worker(std::vector<std::reference_wrapper<commFPGA>> &fpgas);
  12. ~Worker();
  13. void start();
  14. int assignJobList(JobList &jobList);
  15. private:
  16. std::mutex currentJobList_m;
  17. JobList *currentJobList = NULL;
  18. std::vector<std::reference_wrapper<commFPGA>> *fpgaVector;
  19. commFPGA* findAvailableFPGA();
  20. std::future<int> result;
  21. int threadMain();
  22. std::condition_variable hasJobList;
  23. void waitForJobList();
  24. };
  25. #endif