MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / GetCoreIdForThread

Method GetCoreIdForThread

tests/unit_test/mocks/test_environment_state.cpp:76–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76auto TestEnvironmentState::GetCoreIdForThread(std::thread::id tid) -> size_t {
77 std::lock_guard<std::mutex> lock(map_mutex_);
78 auto it = thread_to_core_map_.find(tid);
79 if (it != thread_to_core_map_.end()) {
80 return it->second;
81 }
82
83 // 自动分配一个核心 ID (兼容旧行为)
84 if (next_core_id_ >= cores_.size()) {
85 // 如果核心未初始化,默认创建单核环境
86 if (cores_.empty()) {
87 cores_.emplace_back(0);
88 }
89 next_core_id_ = 0;
90 }
91
92 size_t new_id = next_core_id_;
93 thread_to_core_map_[tid] = new_id;
94 cores_[new_id].thread_id = tid;
95 next_core_id_ = (next_core_id_ + 1) % cores_.size();
96 return new_id;
97}
98
99auto TestEnvironmentState::GetCurrentCoreEnv() -> CoreEnvironment& {
100 auto tid = std::this_thread::get_id();

Callers 1

GetCurrentCoreIdFunction · 0.80

Calls 2

sizeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected