mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 10:00:44 +08:00
perf: 修改异步加载资源的方式
This commit is contained in:
@@ -7,27 +7,15 @@
|
||||
|
||||
bool asst::AbstractConfig::load(const std::filesystem::path& path)
|
||||
{
|
||||
return _load(path);
|
||||
}
|
||||
std::string class_name = utils::demangle(typeid(*this).name());
|
||||
|
||||
void asst::AbstractConfig::async_load(const std::filesystem::path& path)
|
||||
{
|
||||
m_load_future = std::async(std::launch::async, &AbstractConfig::_load, this, path);
|
||||
}
|
||||
|
||||
bool asst::AbstractConfig::_load(std::filesystem::path path)
|
||||
{
|
||||
if (!std::filesystem::exists(path) || !std::filesystem::is_regular_file(path)) {
|
||||
std::string class_name = utils::demangle(typeid(*this).name());
|
||||
Log.error(class_name, "file does not exist", path);
|
||||
Log.error(class_name, __FUNCTION__, "file does not exist", path);
|
||||
return false;
|
||||
}
|
||||
m_path = path;
|
||||
|
||||
std::unique_lock lock(m_load_mutex);
|
||||
|
||||
std::string class_name = utils::demangle(typeid(*this).name());
|
||||
LogTraceScope(class_name);
|
||||
LogTraceScope(class_name + " :: " + __FUNCTION__);
|
||||
Log.info(path);
|
||||
|
||||
auto ret = json::open(path, true);
|
||||
|
||||
Reference in New Issue
Block a user