Implement get_scheduler_thread_id without threads.

This commit is contained in:
levlam 2022-11-09 18:11:48 +03:00
parent 8b4bc80860
commit 71e3011afa
2 changed files with 8 additions and 0 deletions

View File

@ -70,11 +70,13 @@ void ConcurrentScheduler::test_one_thread_run() {
} while (!is_finished_.load(std::memory_order_relaxed));
}
#if !TD_THREAD_UNSUPPORTED
thread::id ConcurrentScheduler::get_scheduler_thread_id(int32 sched_id) {
auto thread_pos = static_cast<size_t>(sched_id - 1);
CHECK(thread_pos < threads_.size());
return threads_[thread_pos].get_id();
}
#endif
void ConcurrentScheduler::start() {
CHECK(state_ == State::Start);

View File

@ -50,7 +50,13 @@ class ConcurrentScheduler final : private Scheduler::Callback {
return is_finished_.load(std::memory_order_relaxed);
}
#if TD_THREAD_UNSUPPORTED
int get_scheduler_thread_id(int32 sched_id) {
return 1;
}
#else
thread::id get_scheduler_thread_id(int32 sched_id);
#endif
void start();