| 120 | |
| 121 | template <typename TaskType> |
| 122 | std::shared_ptr<TimerBase> CreateTimer(ExecutorRef executor, std::chrono::nanoseconds period, |
| 123 | TaskType&& task, bool auto_start = true) { |
| 124 | AIMRT_ASSERT(executor, "Executor is null."); |
| 125 | AIMRT_ASSERT(executor.SupportTimerSchedule(), "Executor does not support timer scheduling."); |
| 126 | AIMRT_ASSERT(period >= std::chrono::nanoseconds::zero(), "Timer period must not be negative."); |
| 127 | auto timer = std::make_shared<Timer<TaskType>>(executor, period, std::forward<TaskType>(task)); |
| 128 | if (auto_start) { |
| 129 | timer->Reset(); |
| 130 | } |
| 131 | return timer; |
| 132 | } |
| 133 | |
| 134 | } // namespace aimrt::executor |
no test coverage detected