CThread.cpp 543 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "stdafx.h"
  2. #include "CThread.h"
  3. CThread::CThread()
  4. {
  5. }
  6. CThread::~CThread()
  7. {
  8. if (!this->isInterrupted())
  9. {
  10. this->interrupt();
  11. }
  12. if (this->th.joinable()) {
  13. this->th.join();
  14. }
  15. }
  16. void CThread::start()
  17. {
  18. std::thread thr(std::bind(&CThread::run, this));
  19. this->th = std::move(thr);
  20. }
  21. std::thread::id CThread::getId()
  22. {
  23. return this->th.get_id();
  24. }
  25. void CThread::interrupt()
  26. {
  27. this->isInterript;
  28. }
  29. bool CThread::isInterrupted()
  30. {
  31. return false;
  32. }
  33. void CThread::join()
  34. {
  35. this->th.join();
  36. }
  37. void CThread::run()
  38. {
  39. }