I assume std::call_once() uses the same technique and therefore has the same excellent performance as dispatch_once.
You can read what it does here:
https://github.com/llvm/llvm-project/blob/main/libcxx/src/call_once.cpp
There is a comment at the start about dispatch_once.
It doesn’t do double-checked locking; it seems to unconditionally lock a pthread_mutex.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: