Merge "Fix std::terminate call in thread pool" into main

This commit is contained in:
jade 2024-10-15 00:11:59 +00:00 committed by Gerrit Code Review
commit f6077314fa

View file

@ -109,8 +109,21 @@ void ThreadPool::doWork(bool mainThread)
try { try {
std::rethrow_exception(exc); std::rethrow_exception(exc);
} catch (std::exception & e) { } catch (std::exception & e) {
if (!dynamic_cast<ThreadPoolShutDown*>(&e)) if (!dynamic_cast<ThreadPoolShutDown*>(&e)) {
ignoreExceptionExceptInterrupt(); // Yes, this is not a destructor, but we cannot
// safely propagate an exception out of here.
//
// What happens is that if we do, shutdown()
// will have join() throw an exception if we
// are on a worker thread, preventing us from
// joining the rest of the threads. Although we
// could make the joining eat exceptions too,
// we could just as well not let Interrupted
// fall out to begin with, since the thread
// will immediately cleanly quit because of
// quit == true anyway.
ignoreExceptionInDestructor();
}
} catch (...) { } catch (...) {
} }
} }