When I use your thread library, I encountered an interesting issue. Is the following conditional redundant? Because theoretically, if our thread is not in a stopped state but the task queue is empty, it shouldn't leave the waiting state.std::unique_lock<std::mutex> lock(this->queue_mutex); this->condition.wait(lock, [this]{ return this->stop || !this->tasks.empty(); }); if(this->stop && this->tasks.empty()) return;
When I use your thread library, I encountered an interesting issue. Is the following conditional redundant? Because theoretically, if our thread is not in a stopped state but the task queue is empty, it shouldn't leave the waiting state.
std::unique_lock<std::mutex> lock(this->queue_mutex); this->condition.wait(lock, [this]{ return this->stop || !this->tasks.empty(); }); if(this->stop && this->tasks.empty()) return;