From c7051ef6067d15efb978e63e8a4155480440fb75 Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 11 Sep 2016 08:54:26 -0400 Subject: [PATCH] Added an error message that prints to STDERR when you accidentally let an exception sit in a thread pool and don't handle it before the thread pool is destroyed. --- dlib/threads/thread_pool_extension.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dlib/threads/thread_pool_extension.h b/dlib/threads/thread_pool_extension.h index e928cd946..43b1258ed 100644 --- a/dlib/threads/thread_pool_extension.h +++ b/dlib/threads/thread_pool_extension.h @@ -505,7 +505,21 @@ namespace dlib ~thread_pool ( ) { - impl->shutdown_pool(); + try + { + impl->shutdown_pool(); + } + catch (std::exception& e) + { + std::cerr << "An unhandled exception was inside a dlib::thread_pool when it was destructed." << std::endl; + std::cerr << "It's what string is: \n" << e.what() << std::endl; + throw; + } + catch (...) + { + std::cerr << "An unhandled exception was inside a dlib::thread_pool when it was destructed." << std::endl; + throw; + } } void wait_for_task (