Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. namespace sf {
  2.  
  3. uint32_t g_index;
  4. std::mutex g_mutex;
  5.  
  6. Bases *initBases(Bases *&self, Bases *parent)
  7. {
  8. std::lock_guard<std::mutex> lg(g_mutex);
  9.  
  10. if (self != nullptr) return self;
  11.  
  12. uint32_t depth = parent ? parent->depth + 1 : 0;
  13. Bases *b = new Bases();
  14. b->depth = depth;
  15. b->index = ++g_index;
  16. memset(b->bases, 0, sizeof(b->bases));
  17. memcpy(b->bases, parent->bases, depth * sizeof(uint32_t));
  18. b->bases[depth] = b->index;
  19.  
  20. std::atomic_thread_fence(std::memory_order_release);
  21.  
  22. self = b;
  23. return b;
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement