Fix std::thread assertion on destruction

Fixes: #979
This commit is contained in:
Jerry Zhang 2025-01-06 12:28:35 -08:00
parent 8451ee724a
commit 9c4bbad4ec
2 changed files with 14 additions and 4 deletions

View File

@ -66,16 +66,22 @@ void Executor::SubmissionProcessor::pushOneTask(CoroutineHandle* task) {
}
void Executor::SubmissionProcessor::stop() {
m_isRunning = false;
m_processor.stop();
if (m_isRunning) {
m_isRunning = false;
m_processor.stop();
}
}
void Executor::SubmissionProcessor::join() {
m_thread.join();
if (m_thread.joinable()) {
m_thread.join();
}
}
void Executor::SubmissionProcessor::detach() {
m_thread.detach();
if (m_thread.joinable()) {
m_thread.detach();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -54,6 +54,10 @@ private:
std::thread m_thread;
public:
SubmissionProcessor();
~SubmissionProcessor() override {
stop();
join();
}
public:
template<typename CoroutineType, typename ... Args>