MCPcopy Create free account
hub / github.com/AimRT/AimRT / Initialize

Method Initialize

src/runtime/core/executor/main_thread_executor.cc:41–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace aimrt::runtime::core::executor {
40
41void 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
66void MainThreadExecutor::Start() {
67 AIMRT_CHECK_ERROR_THROW(

Callers

nothing calls this directly

Calls 4

SetNameForCurrentThreadFunction · 0.85
BindCpuForCurrentThreadFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected