| 29 | } |
| 30 | |
| 31 | void ParallelQuery(int num_threads, |
| 32 | int num_times_per_replica, int num_replicas, |
| 33 | std::vector<std::atomic_int> *counters) { |
| 34 | EXPECT_EQ(0, num_replicas * num_times_per_replica % num_threads); |
| 35 | int num_times = num_replicas * num_times_per_replica / num_threads; |
| 36 | std::vector<std::thread> threads; |
| 37 | for (int i = 0; i < num_threads; ++i) { |
| 38 | threads.emplace_back( |
| 39 | [num_times, counters, this] { |
| 40 | std::vector<int> local_counters(counters->size()); |
| 41 | for (int i = 0; i < num_times; ++i) { |
| 42 | const std::string &host_port = |
| 43 | rpc_manager_.GetChannel()->host_port(); |
| 44 | ++local_counters[std::stoi(host_port)]; |
| 45 | } |
| 46 | for (size_t i = 0; i < counters->size(); ++i) { |
| 47 | (*counters)[i] += local_counters[i]; |
| 48 | } |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | for (auto &thread : threads) { |
| 53 | thread.join(); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | testing::MockRpcManager rpc_manager_; |
| 58 | std::shared_ptr<ServerRegister> regs_; |
nothing calls this directly
no test coverage detected