You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 rivejä
746 B

  1. #include <iostream>
  2. #include <ecs/core/utils/fixed_function.inl>
  3. #include <ecs/core/utils/thread_pool/worker.inl>
  4. using namespace ::ecs::core::utils;
  5. void thread_pool_worker
  6. ::run()
  7. {
  8. _state = state::running;
  9. while (_state == state::running)
  10. {
  11. task t;
  12. if (pop(t, std::chrono::milliseconds(500)))
  13. {
  14. try
  15. {
  16. t(_thread_id);
  17. }
  18. catch(const std::exception& ex)
  19. {
  20. std::cerr << "error in worker thread: " << ex.what() << std::endl;
  21. }
  22. catch(...)
  23. {
  24. std::cerr << "error in worker thread: unknown" << std::endl;
  25. }
  26. }
  27. }
  28. _state = state::finished;
  29. }