executor: shut down idle threads in the blocking pool (#1514)

This commit is contained in:
Jarred Nicholls
2019-08-30 08:26:16 -07:00
committed by Carl Lerche
parent 15dc0563b7
commit 3d9134d13e
+5 -1
View File
@@ -109,12 +109,16 @@ fn spawn_thread() {
shared.num_idle += 1;
loop {
shared = POOL.condvar.wait_timeout(shared, KEEP_ALIVE).unwrap().0;
let lock_result = POOL.condvar.wait_timeout(shared, KEEP_ALIVE).unwrap();
shared = lock_result.0;
let timeout_result = lock_result.1;
if let Some(task) = shared.queue.pop_front() {
drop(shared);
run_task(task);
continue 'outer;
} else if timeout_result.timed_out() {
break 'outer;
}
}
}