Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gwq5210 committed Aug 16, 2022
1 parent e669feb commit bfb4814
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/gtl/thread/thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ bool ThreadPool::Start(size_t thread_count) {
for (size_t i = 0; i < thread_count; ++i) {
threads_.emplace_back([this]() { this->Run(); });
}
stop_ = false;
return true;
}

bool ThreadPool::AddTask(std::function<void(void)>&& task) {
if (stop_) {
if (threads_.empty()) {
return false;
}
mutex_.Lock();
Expand Down
2 changes: 1 addition & 1 deletion src/gtl/thread/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ThreadPool : public IThreadPool {

void Run();

std::atomic_bool stop_{true};
std::atomic_bool stop_{false};
Mutex mutex_;
CondVar cond_var_;
Vector<Thread> threads_;
Expand Down

0 comments on commit bfb4814

Please sign in to comment.