Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //--- ------------------------------------------------------------------------
  2. void test(size_t current, size_t end)
  3. {
  4. //Some code here
  5. }
  6. void checkDistance()
  7. {
  8. auto numThreads = 2; //std::thread::hardware_concurrency();
  9. std::vector<std::thread> threads;
  10.  
  11. auto blockSize = 1;
  12.  
  13. cout<<"numThreads="<<numThreads <<"blockSize="<<blockSize<<"n";
  14.  
  15. for(size_t i = 0; i < numThreads - 1; ++i)
  16. threads.emplace_back(test, i * blockSize, (i+1) * blockSize);
  17.  
  18. test((numThreads-1) * blockSize, 5);
  19.  
  20. for(auto& thread : threads)
  21. thread.join();
  22. }
  23.  
  24.  
  25. int main(int argc, char** argv) {
  26. checkDistance();
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement