feat: lazy init

This commit is contained in:
Dexrn ZacAttack
2026-01-23 18:15:18 -08:00
parent 32fff263a3
commit 3b625a7caa
3 changed files with 13 additions and 1 deletions

View File

@@ -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)

View File

@@ -13,7 +13,11 @@ namespace wd::common {
WinDurango() = default;
void Init();
Config Config;
private:
bool _inited = false;
};
}

View File

@@ -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;
}
}