| 39 | namespace aimrt::runtime::core::executor { |
| 40 | |
| 41 | void MainThreadExecutor::Initialize(YAML::Node options_node) { |
| 42 | AIMRT_CHECK_ERROR_THROW( |
| 43 | std::atomic_exchange(&state_, State::kInit) == State::kPreInit, |
| 44 | "Main thread executor can only be initialized once."); |
| 45 | |
| 46 | if (options_node && !options_node.IsNull()) |
| 47 | options_ = options_node.as<Options>(); |
| 48 | |
| 49 | name_ = options_.name; |
| 50 | |
| 51 | try { |
| 52 | util::SetNameForCurrentThread(name_); |
| 53 | util::BindCpuForCurrentThread(options_.thread_bind_cpu); |
| 54 | util::SetCpuSchedForCurrentThread(options_.thread_sched_policy); |
| 55 | } catch (const std::exception& e) { |
| 56 | AIMRT_WARN("Set thread policy for main thread get exception, {}", e.what()); |
| 57 | } |
| 58 | |
| 59 | main_thread_id_ = std::this_thread::get_id(); |
| 60 | |
| 61 | options_node = options_; |
| 62 | |
| 63 | AIMRT_INFO("Main thread executor init complete"); |
| 64 | } |
| 65 | |
| 66 | void MainThreadExecutor::Start() { |
| 67 | AIMRT_CHECK_ERROR_THROW( |
nothing calls this directly
no test coverage detected