From c652919954e1266c55948cb6cf03436d7940437c Mon Sep 17 00:00:00 2001 From: Johan Jansen Date: Thu, 31 Oct 2019 21:48:48 +0100 Subject: [PATCH] Do not use shared_ptr where not required --- httplib.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/httplib.h b/httplib.h index 1540ea1..3d9f0d4 100644 --- a/httplib.h +++ b/httplib.h @@ -370,8 +370,7 @@ class ThreadPool : public TaskQueue { public: explicit ThreadPool(size_t n) : shutdown_(false) { while (n) { - auto t = std::make_shared(worker(*this)); - threads_.push_back(t); + threads_.emplace_back(worker(*this)); n--; } } @@ -395,8 +394,8 @@ public: cond_.notify_all(); // Join... - for (auto t : threads_) { - t->join(); + for (auto& t : threads_) { + t.join(); } } @@ -428,7 +427,7 @@ private: }; friend struct worker; - std::vector> threads_; + std::vector threads_; std::list> jobs_; bool shutdown_;