From 71e3011afab47dd132f3604a7d5a9f776b16f228 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 9 Nov 2022 18:11:48 +0300 Subject: [PATCH] Implement get_scheduler_thread_id without threads. --- tdactor/td/actor/ConcurrentScheduler.cpp | 2 ++ tdactor/td/actor/ConcurrentScheduler.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tdactor/td/actor/ConcurrentScheduler.cpp b/tdactor/td/actor/ConcurrentScheduler.cpp index ef8b802d3..9a3cf2133 100644 --- a/tdactor/td/actor/ConcurrentScheduler.cpp +++ b/tdactor/td/actor/ConcurrentScheduler.cpp @@ -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(sched_id - 1); CHECK(thread_pos < threads_.size()); return threads_[thread_pos].get_id(); } +#endif void ConcurrentScheduler::start() { CHECK(state_ == State::Start); diff --git a/tdactor/td/actor/ConcurrentScheduler.h b/tdactor/td/actor/ConcurrentScheduler.h index 8766db733..3f574de5e 100644 --- a/tdactor/td/actor/ConcurrentScheduler.h +++ b/tdactor/td/actor/ConcurrentScheduler.h @@ -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();