Skip to content

Commit

Permalink
synchronize test collector
Browse files Browse the repository at this point in the history
  • Loading branch information
dhconnelly committed Nov 28, 2024
1 parent b78f084 commit c2c125d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/http/server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ TEST(HttpServer, CallConcurrently) {
int num_clients = 10;
int num_requests = 10;
std::vector<std::thread> threads(num_clients);
std::mutex mux;
std::vector<std::string> results;
for (int i = 0; i < num_clients; i++) {
threads[i] = std::thread([&results, &ready, num_requests, port] {
ready.wait(false);
for (int j = 0; j < num_requests; j++) {
results.push_back(Call(port, Method::GET, "/foo"));
}
});
threads[i] =
std::thread([&mux, &results, &ready, num_requests, port] {
ready.wait(false);
for (int j = 0; j < num_requests; j++) {
std::scoped_lock guard(mux);
results.push_back(Call(port, Method::GET, "/foo"));
}
});
}
ready = true;
ready.notify_all();
Expand Down

0 comments on commit c2c125d

Please sign in to comment.