mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-16 01:38:28 +00:00
Fixed thread pool problem.
This commit is contained in:
parent
1b95bf8cc3
commit
3629f87627
1 changed files with 9 additions and 6 deletions
|
@ -335,6 +335,8 @@ private:
|
||||||
|
|
||||||
void operator()() {
|
void operator()() {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
std::function<void()> fn;
|
||||||
|
{
|
||||||
std::unique_lock<std::mutex> lock(pool_.mutex_);
|
std::unique_lock<std::mutex> lock(pool_.mutex_);
|
||||||
|
|
||||||
pool_.cond_.wait(
|
pool_.cond_.wait(
|
||||||
|
@ -342,8 +344,9 @@ private:
|
||||||
|
|
||||||
if (pool_.shutdown_) { break; }
|
if (pool_.shutdown_) { break; }
|
||||||
|
|
||||||
auto fn = pool_.jobs_.front();
|
fn = pool_.jobs_.front();
|
||||||
pool_.jobs_.pop_front();
|
pool_.jobs_.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
assert(true == (bool)fn);
|
assert(true == (bool)fn);
|
||||||
fn();
|
fn();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue