CHECK that ThreadPool is given a positive num_threads (#1800)

Signed-off-by: Mac Mason <mac@kingseye.net>
master
Mac Mason 2021-01-20 01:37:10 -08:00 committed by GitHub
parent 802e9f131b
commit 018dded2f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -37,6 +37,7 @@ void ThreadPoolInterface::SetThreadPool(Task* task) {
} }
ThreadPool::ThreadPool(int num_threads) { ThreadPool::ThreadPool(int num_threads) {
CHECK_GT(num_threads, 0) << "ThreadPool requires a positive num_threads!";
absl::MutexLock locker(&mutex_); absl::MutexLock locker(&mutex_);
for (int i = 0; i != num_threads; ++i) { for (int i = 0; i != num_threads; ++i) {
pool_.emplace_back([this]() { ThreadPool::DoWork(); }); pool_.emplace_back([this]() { ThreadPool::DoWork(); });