17 #ifndef CYBER_TASK_TASK_MANAGER_H_ 18 #define CYBER_TASK_TASK_MANAGER_H_ 24 #include <type_traits> 40 template <
typename F,
typename... Args>
42 -> std::future<
typename std::result_of<F(Args...)>::type> {
43 using return_type =
typename std::result_of<F(Args...)>::type;
44 auto task = std::make_shared<std::packaged_task<return_type()>>(
45 std::bind(std::forward<F>(
func), std::forward<Args>(args)...));
47 task_queue_->Enqueue([task]() { (*task)(); });
48 for (
auto& task : tasks_) {
52 std::future<return_type> res(task->get_future());
57 uint32_t num_threads_ = 0;
58 uint32_t task_queue_size_ = 1000;
59 std::atomic<bool> stop_ = {
false};
60 std::vector<uint64_t> tasks_;
61 std::shared_ptr<base::BoundedQueue<std::function<void()>>> task_queue_;
68 #endif // CYBER_TASK_TASK_MANAGER_H_ void(* func)(void *)
Definition: routine_context.h:41
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
auto Enqueue(F &&func, Args &&... args) -> std::future< typename std::result_of< F(Args...)>::type >
Definition: task_manager.h:41
bool NotifyTask(uint64_t crid)
Definition: task_manager.h:34