31 #include <MUtils/Exception.h> 34 #include <QAtomicPointer> 48 template<
typename T>
class Lazy 51 Lazy(std::function<T*(
void)> &&initializer) : m_initializer(initializer) { }
57 if (T *
const value = m_initializer())
59 if (!m_value.testAndSetOrdered(NULL, value))
66 MUTILS_THROW(
"Initializer returned NULL!");
73 QAtomicPointer<T> m_value;
74 const std::function<T*(void)> m_initializer;
This file contains miscellaneous functions that are generally useful for Qt-based applications...
Lazy initialization template class.
Definition: Lazy.h:48
Global MUtils namespace.
Definition: CPUFeatures.h:37