File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -370,8 +370,7 @@ class ThreadPool : public TaskQueue {
370370public:
371371 explicit ThreadPool (size_t n) : shutdown_(false ) {
372372 while (n) {
373- auto t = std::make_shared<std::thread>(worker (*this ));
374- threads_.push_back (t);
373+ threads_.emplace_back (worker (*this ));
375374 n--;
376375 }
377376 }
@@ -395,8 +394,8 @@ class ThreadPool : public TaskQueue {
395394 cond_.notify_all ();
396395
397396 // Join...
398- for (auto t : threads_) {
399- t-> join ();
397+ for (auto & t : threads_) {
398+ t. join ();
400399 }
401400 }
402401
@@ -428,7 +427,7 @@ class ThreadPool : public TaskQueue {
428427 };
429428 friend struct worker ;
430429
431- std::vector<std::shared_ptr<std:: thread> > threads_;
430+ std::vector<std::thread> threads_;
432431 std::list<std::function<void ()>> jobs_;
433432
434433 bool shutdown_;
You can’t perform that action at this time.
0 commit comments