Guest User

Untitled

a guest
Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. class Something {
  2. public:
  3. int value;
  4. };
  5. auto&& pointer = std::atomic<Something*>{nullptr};
  6.  
  7. // thread 1
  8. auto value = Something{1};
  9. pointer.set(&value, std::memory_order_relaxed);
  10.  
  11. // thread 2
  12. Something* something = nullptr;
  13. while (!(something = pointer.load(std::memory_order_relaxed))) {}
  14. cout << something.value << endl;
Add Comment
Please, Sign In to add comment