Skip to content

Commit 79a2de5

Browse files
authored
Update web-crawler-multithreaded.cpp
1 parent 2cf976b commit 79a2de5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

C++/web-crawler-multithreaded.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Solution {
1515
q_.emplace(startUrl);
1616
unordered_set<string> lookup = {startUrl};
1717
vector<thread> workers;
18-
const auto& worker = [this, &htmlParser](unordered_set<string> *lookup) {
18+
const auto& worker = [this](HtmlParser *htmlParser, unordered_set<string> *lookup) {
1919
while (true) {
2020
string from_url;
2121
{
@@ -28,7 +28,7 @@ class Solution {
2828
++working_count_;
2929
}
3030
const auto& name = hostname(from_url);
31-
for (const auto& to_url: htmlParser.getUrls(from_url)) {
31+
for (const auto& to_url: htmlParser->getUrls(from_url)) {
3232
if (name != hostname(to_url)) {
3333
continue;
3434
}
@@ -49,7 +49,7 @@ class Solution {
4949
}
5050
};
5151
for (int i = 0; i < NUMBER_OF_WORKERS; ++i) {
52-
workers.emplace_back(worker, &lookup);
52+
workers.emplace_back(worker, &htmlParser, &lookup);
5353
}
5454
{
5555
unique_lock<mutex> lock{m_};

0 commit comments

Comments
 (0)