Once.h provides a way to run a function once without relying on system libraries at the call site. It also allows use of any function as long as it satisfies the VoidFunction concept. For similarity with the STL I would have preferred it to be in AK, but it needs a mutex to work so that would cause a circular dependency. With some templates and an optional it could be modified to return non void types, but since that isn't an existing pattern in the codebase that could be implemented in a follow-up. Performance wise compared to pthread_once it should be very similar in the already initialized case as both use an atomic. On the first call this might be slightly slower since we use a mutex while pthread may be doing something fancier with a futex or similar, but it shouldn't matter. |
||
|---|---|---|
| .. | ||
| BackgroundAction.cpp | ||
| BackgroundAction.h | ||
| CMakeLists.txt | ||
| ConditionVariable.h | ||
| Forward.h | ||
| Mutex.h | ||
| MutexProtected.h | ||
| Once.h | ||
| RWLock.h | ||
| RWLockProtected.h | ||
| Thread.cpp | ||
| Thread.h | ||
| ThreadPool.cpp | ||
| ThreadPool.h | ||