CYILazy is a thread-safe lazy initializer of a class. The instance pointer remains null until CYILazy::Get() is called, which will trigger a thread-safe initialization of the instance. Also, a CYILazy::TryGet() is available, which will return the actual value while not instantiating, providing a convenient way to test for nullptr in the event that the user does not want the instantiation to occur.
Usage example:
#include <utility/YiLazy.h>
Public Member Functions | |
CYILazy () | |
~CYILazy () | |
const YI_CLASS * | Get () const |
YI_CLASS * | Get () |
const YI_CLASS * | TryGet () const |
YI_CLASS * | TryGet () |
const YI_CLASS* CYILazy< YI_CLASS >::Get | ( | ) | const |
This getter returns the pointer of the instance. The instance will also be instantiated if not instantiated.
YI_CLASS* CYILazy< YI_CLASS >::Get | ( | ) |
This getter returns the pointer of the instance. The instance will also be instantiated if not instantiated.
const YI_CLASS* CYILazy< YI_CLASS >::TryGet | ( | ) | const |
This getter returns the pointer of the instance. The instance will not be instantiated and may return nullptr.
YI_CLASS* CYILazy< YI_CLASS >::TryGet | ( | ) |
This getter returns the pointer of the instance. The instance will not be instantiated and may return nullptr.