Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

PaulPaulAga Apr 9th, 2020 152 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void SearchServer::AddQueriesStreamMultiThread(istream &query_input,
  3.                                                ostream &search_results_output)
  4. {
  5.     vector<future<vector<string>>> compute_query;
  6.     vector<string> current_batch;
  7.     const size_t batch_size = 1500;
  8.     size_t current_batch_size = 0;
  9.     for (string current_query; getline(query_input, current_query);)
  10.     {
  11.         current_batch.push_back(current_query);
  12.         ++current_batch_size;
  13.         if (current_batch_size == batch_size)
  14.         {
  15.             compute_query.push_back(async([this, current_batch]() {
  16.                 return this->handleQueryVector(current_batch);
  17.             }));
  18.             current_batch.clear();
  19.             current_batch_size = 0;
  20.         }
  21.     }
  22.     if (current_batch_size != 0)
  23.         compute_query.push_back(async([this, &current_batch]() {
  24.             return this->handleQueryVector(current_batch);
  25.         }));
  26.  
  27.     for (auto &thread: compute_query)
  28.         for (const auto &result: thread.get())
  29.             search_results_output << result << endl;
  30.  
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top