SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
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