From 018dded2f9a0adb7e77003d05662ada251b541f5 Mon Sep 17 00:00:00 2001 From: Mac Mason Date: Wed, 20 Jan 2021 01:37:10 -0800 Subject: [PATCH] CHECK that ThreadPool is given a positive num_threads (#1800) Signed-off-by: Mac Mason --- cartographer/common/thread_pool.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/cartographer/common/thread_pool.cc b/cartographer/common/thread_pool.cc index c6295f8..2457152 100644 --- a/cartographer/common/thread_pool.cc +++ b/cartographer/common/thread_pool.cc @@ -37,6 +37,7 @@ void ThreadPoolInterface::SetThreadPool(Task* task) { } ThreadPool::ThreadPool(int num_threads) { + CHECK_GT(num_threads, 0) << "ThreadPool requires a positive num_threads!"; absl::MutexLock locker(&mutex_); for (int i = 0; i != num_threads; ++i) { pool_.emplace_back([this]() { ThreadPool::DoWork(); });