5 #include "src/base/once.h" 13 #include "src/base/atomicops.h" 18 void CallOnceImpl(OnceType* once, std::function<
void()> init_func) {
19 AtomicWord state = Acquire_Load(once);
21 if (state == ONCE_STATE_DONE) {
32 state = Acquire_CompareAndSwap(
33 once, ONCE_STATE_UNINITIALIZED, ONCE_STATE_EXECUTING_FUNCTION);
34 if (state == ONCE_STATE_UNINITIALIZED) {
38 Release_Store(once, ONCE_STATE_DONE);
42 while (state == ONCE_STATE_EXECUTING_FUNCTION) {
48 state = Acquire_Load(once);