\r
#include "../exception/win32_exception.h"\r
#include "../utility/string.h"\r
+#include "../utility/move_on_copy.h"\r
#include "../log/log.h"\r
\r
#include <tbb/atomic.h>\r
below_normal_priority_class\r
};\r
\r
-namespace internal\r
-{\r
- template<typename T>\r
- struct move_on_copy\r
- {\r
- move_on_copy(const move_on_copy<T>& other) : value(std::move(other.value)){}\r
- move_on_copy(T&& value) : value(std::move(value)){}\r
- mutable T value;\r
- };\r
-\r
- template<typename T>\r
- move_on_copy<T> make_move_on_copy(T&& value)\r
- {\r
- return move_on_copy<T>(std::move(value));\r
- }\r
-}\r
-\r
class executor : boost::noncopyable\r
{\r
const std::string name_;\r
virtual ~executor() // noexcept\r
{\r
stop();\r
+ execution_queue_[normal_priority].try_push([]{}); // Wake the execution thread.\r
join();\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
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 = internal::make_move_on_copy(create_task(func));\r
+ auto task_adaptor = make_move_on_copy(create_task(func));\r
\r
auto future = task_adaptor.value.get_future();\r
\r
auto try_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 = internal::make_move_on_copy(create_task(func));\r
+ auto task_adaptor = make_move_on_copy(create_task(func));\r
\r
auto future = task_adaptor.value.get_future();\r
\r