Browse Source

Merge pull request #124 from paullouisageneau/fix-threadpool-destruction

Fix ThreadPool static destruction issues
Paul-Louis Ageneau 5 years ago
parent
commit
503a5d8a51
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/threadpool.cpp

+ 3 - 2
src/threadpool.cpp

@@ -21,8 +21,9 @@
 namespace rtc {
 namespace rtc {
 
 
 ThreadPool &ThreadPool::Instance() {
 ThreadPool &ThreadPool::Instance() {
-	static ThreadPool instance;
-	return instance;
+	// Init handles joining on cleanup
+	static ThreadPool *instance = new ThreadPool;
+	return *instance;
 }
 }
 
 
 ThreadPool::~ThreadPool() { join(); }
 ThreadPool::~ThreadPool() { join(); }