mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-01-31 00:55:17 +01:00
feat: lazy init
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(WinDurango.Common VERSION 1.0.0)
|
||||
|
||||
set(VERSION_SUFFIX "-dev.3") # used for non-stable versions, otherwise blank
|
||||
set(VERSION_SUFFIX "-dev.4") # used for non-stable versions, otherwise blank
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@ namespace wd::common {
|
||||
|
||||
WinDurango() = default;
|
||||
|
||||
void Init();
|
||||
|
||||
Config Config;
|
||||
private:
|
||||
bool _inited = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,15 @@
|
||||
namespace wd::common {
|
||||
WinDurango *WinDurango::GetInstance() {
|
||||
static WinDurango Instance = WinDurango(); // if we don't declare it in src, it will make multiple instances per header import in different libs afaik
|
||||
if (!Instance._inited)
|
||||
Instance.Init(); // lazy
|
||||
|
||||
return &Instance;
|
||||
}
|
||||
|
||||
void WinDurango::Init() {
|
||||
// todo load config
|
||||
|
||||
this->_inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user