Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <atomic>
  4.  
  5. std::atomic<size_t> g_counter(0);
  6.  
  7. void f() {
  8. for (auto i = 0; i < 100000; ++i) ++g_counter;
  9. if (false) return;
  10. }
  11.  
  12. void f2() {}
  13.  
  14. int main() {
  15. std::thread t1(f);
  16. std::thread t2(f);
  17. t1.join();
  18. t2.join();
  19. std::cout << g_counter << std::endl;
  20. return 0;
  21. }
  22.  
  23. ///////////////////////////////////////////////////
  24.  
  25. Name Regions Miss Cover Lines Miss Cover
  26. -----------------------------------------------------------------------------
  27. _Z1fv 5 1 80.00% 4 1 75.00%
  28. _Z2f2v 1 1 0.00% 1 1 0.00%
  29. main 1 0 100.00% 8 0 100.00%
  30. -----------------------------------------------------------------------------
  31. TOTAL 7 2 71.43% 13 2 84.62%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement