Skip to content

Commit c652919

Browse files
committed
Do not use shared_ptr where not required
1 parent 58753ba commit c652919

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

httplib.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,7 @@ class ThreadPool : public TaskQueue {
370370
public:
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_;

0 commit comments

Comments
 (0)