17 #ifndef CYBER_TASK_TASK_H_ 18 #define CYBER_TASK_TASK_H_ 30 template <
typename F,
typename... Args>
31 static auto Async(F&& f, Args&&... args)
32 -> std::future<
typename std::result_of<F(Args...)>::type> {
35 std::forward<Args>(args)...)
38 std::bind(std::forward<F>(f), std::forward<Args>(args)...));
41 static inline void Yield() {
45 std::this_thread::yield();
49 template <
typename Rep,
typename Period>
50 static void SleepFor(
const std::chrono::duration<Rep, Period>& sleep_duration) {
52 if (routine ==
nullptr) {
53 std::this_thread::sleep_for(sleep_duration);
55 routine->Sleep(sleep_duration);
59 static inline void USleep(useconds_t usec) {
61 if (routine ==
nullptr) {
62 std::this_thread::sleep_for(std::chrono::microseconds{usec});
71 #endif // CYBER_TASK_TASK_H_ PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
static CRoutine * GetCurrentRoutine()
Definition: croutine.h:135
static void Yield()
Definition: croutine.h:131
std::chrono::microseconds Duration
Definition: croutine.h:36
Definition: global_data.h:40