Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace sf {
- uint32_t g_index;
- std::mutex g_mutex;
- Bases *initBases(Bases *&self, Bases *parent)
- {
- std::lock_guard<std::mutex> lg(g_mutex);
- if (self != nullptr) return self;
- uint32_t depth = parent ? parent->depth + 1 : 0;
- Bases *b = new Bases();
- b->depth = depth;
- b->index = ++g_index;
- memset(b->bases, 0, sizeof(b->bases));
- memcpy(b->bases, parent->bases, depth * sizeof(uint32_t));
- b->bases[depth] = b->index;
- std::atomic_thread_fence(std::memory_order_release);
- self = b;
- return b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement