worker.hpp 748 B

1234567891011121314151617181920212223242526272829303132333435363738
  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::unique_ptr<commFPGA>> *fpgas);
  12. ~Worker();
  13. void startAsync();
  14. void startSync();
  15. int assignJobList(std::shared_ptr<JobList> &jobList);
  16. private:
  17. std::mutex currentJobList_m;
  18. std::shared_ptr<JobList> currentJobList = NULL;
  19. std::vector<std::unique_ptr<commFPGA>> *fpgaVector;
  20. commFPGA* findAvailableFPGA();
  21. void sendJob(std::shared_ptr<Job> &job);
  22. std::future<int> result;
  23. int threadMain();
  24. std::condition_variable hasJobList;
  25. void waitForJobList();
  26. };
  27. #endif