Concurrent.h 396 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include <thread>
  3. #include <mutex>
  4. #include <condition_variable>
  5. class Concurrent
  6. {
  7. public:
  8. Concurrent();
  9. ~Concurrent();
  10. void start();
  11. void pause();
  12. void reset();
  13. protected:
  14. bool checkCancel();
  15. void checkPaused();
  16. private:
  17. bool paused = false;
  18. bool cancel = false;
  19. std::thread* thread = nullptr;
  20. std::mutex mutex;
  21. std::condition_variable cv;
  22. void virtual run();
  23. };