1 #ifndef _NNDEPLOY_THREAD_POOL_RUNNABLE_TASK_H_
2 #define _NNDEPLOY_THREAD_POOL_RUNNABLE_TASK_H_
8 namespace thread_pool {
12 explicit TaskBased() =
default;
13 virtual void call() = 0;
14 virtual ~TaskBased() =
default;
17 template <typename F, typename T = typename std::decay<F>::type>
18 struct TaskDerived : TaskBased {
20 explicit TaskDerived(F &&func) : func_(std::forward<F>(func)) {}
21 void call()
override { func_(); }
28 RunnableTask(F &&f) : impl_(new TaskDerived<F>(std::forward<F>(f))) {}
41 impl_ = std::move(task.impl_);
46 std::unique_ptr<TaskBased> impl_;
RunnableTask & operator=(RunnableTask &&task) noexcept
RunnableTask(RunnableTask &&task) noexcept