- task_adaptor_t(const task_adaptor_t& other) : task(std::move(other.task)){}\r
- task_adaptor_t(task_type&& task) : task(std::move(task)){}\r
- void operator()() const { task(); }\r
- mutable task_type task;\r
- } task_adaptor(std::move(task));\r
+ if(p == high_priority_class)\r
+ SetThreadPriority(GetCurrentThread(), HIGH_PRIORITY_CLASS);\r
+ if(p == above_normal_priority_class)\r
+ SetThreadPriority(GetCurrentThread(), ABOVE_NORMAL_PRIORITY_CLASS);\r
+ else if(p == normal_priority_class)\r
+ SetThreadPriority(GetCurrentThread(), NORMAL_PRIORITY_CLASS);\r
+ else if(p == below_normal_priority_class)\r
+ SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS);\r
+ });\r
+ }\r
+ \r
+ void stop() // noexcept\r
+ {\r
+ is_running_ = false; \r
+ execution_queue_[normal_priority].try_push([]{}); // Wake the execution thread.\r
+ }\r
+\r
+ void wait() // noexcept\r
+ {\r
+ invoke([]{});\r
+ }\r
+\r
+ void join()\r
+ {\r
+ if(boost::this_thread::get_id() != thread_.get_id())\r
+ thread_.join();\r
+ }\r
+ \r
+ template<typename Func>\r
+ auto begin_invoke(Func&& func, task_priority priority = normal_priority) -> boost::unique_future<decltype(func())> // noexcept\r
+ { \r
+ // Create a move on copy adaptor to avoid copying the functor into the queue, tbb::concurrent_queue does not support move semantics.\r
+ auto task_adaptor = make_move_on_copy(create_task(func));\r