diff --git a/docs/d0/dce/class_m_utils_1_1_lazy.html b/docs/d0/dce/class_m_utils_1_1_lazy.html index e231d5c..e263478 100644 --- a/docs/d0/dce/class_m_utils_1_1_lazy.html +++ b/docs/d0/dce/class_m_utils_1_1_lazy.html @@ -65,10 +65,9 @@ $(function() {
Public Member Functions | |
+ | Lazy (std::function< T *(void)> &&initializer) |
T & | operator* (void) |
-Protected Member Functions | |
-virtual T * | create ()=0 |
Lazy initialization template class.
-In order to create your own "lazy" initializer, inherit from the Lazy<T>
class an implement the create() function. The lazy-initialized value can be obtained from a Lazy<T>
instance by using the operator*()
. Initialization of the value happens when the operator*()
is called for the very first time, by invoking the concrete create() function. The return value of create() is then stored internally, so that any subsequent call to the operator*()
immediately returns the previously created value.
Note on thread-saftey: This class is thread-safe in the sense that all calls to operator*()
on the same Lazy<T>
instance, regardless from which thread, are guaranteed to return the exactly same value/object. Still, if the value has not been initialized yet and if multiple threads happen to call operator*()
at the same time, then the concrete create() function may be invoked more than once (concurrently and by different threads). In that case, all but one return value of create() are discarded, and all threads eventually receive the same value/object.
The lazy-initialized value of type T can be obtained from a Lazy<T>
instance by using the operator*()
. Initialization of the value happens when the operator*()
is called for the very first time, by invoking the initializer
lambda-function that was passed to the constructor. The return value of the initializer
lambda-function is then stored internally, so that any subsequent call to the operator*()
immediately returns the previously created value.
Note on thread-saftey: This class is thread-safe in the sense that all calls to operator*()
on the same Lazy<T>
instance, regardless from which thread, are guaranteed to return the exactly same value/object. Still, if the value has not been initialized yet and if multiple threads happen to call operator*()
at the same time, then the initializer
lambda-function may be invoked more than once (concurrently and by different threads). In that case, all but one return value of the initializer
lambda-function are discarded, and all threads eventually obtain the same value/object.
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
#include <QScopedPointer>
#include <QAtomicPointer>
#include <functional>
Go to the source code of this file.
create()=0 (defined in MUtils::Lazy< T >) | MUtils::Lazy< T > | protectedpure virtual |
Lazy(std::function< T *(void)> &&initializer) (defined in MUtils::Lazy< T >) | MUtils::Lazy< T > | inline |
operator*(void) (defined in MUtils::Lazy< T >) | MUtils::Lazy< T > | inline |