mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 00:27:42 +00:00
Thread-safe extraction
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "DNAMP2/MLVL.hpp"
|
||||
#include "DNAMP2/STRG.hpp"
|
||||
|
||||
#include "hecl/ClientProcess.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
|
||||
@@ -234,6 +236,8 @@ struct SpecMP2 : SpecBase
|
||||
}
|
||||
progress(_S("MP2 Root"), _S(""), 3, 1.0);
|
||||
|
||||
std::mutex msgLock;
|
||||
hecl::ClientProcess process;
|
||||
int compIdx = 4;
|
||||
prog = 0;
|
||||
for (std::pair<std::string, DNAMP2::PAKBridge*> pair : m_orderedPaks)
|
||||
@@ -245,13 +249,20 @@ struct SpecMP2 : SpecBase
|
||||
const std::string& name = pak.getName();
|
||||
hecl::SystemStringView sysName(name);
|
||||
|
||||
progress(sysName.sys_str().c_str(), _S(""), compIdx, 0.0);
|
||||
m_pakRouter.extractResources(pak, force,
|
||||
[&progress, &sysName, &compIdx](const hecl::SystemChar* substr, float factor)
|
||||
{
|
||||
progress(sysName.sys_str().c_str(), substr, compIdx, factor);
|
||||
std::unique_lock<std::mutex> lk(msgLock);
|
||||
progress(sysName.sys_str().c_str(), _S(""), compIdx, 0.0);
|
||||
}
|
||||
hecl::SystemString pakName = sysName.sys_str();
|
||||
process.addLambdaTransaction([&, pakName](hecl::BlenderToken& btok)
|
||||
{
|
||||
m_pakRouter.extractResources(pak, force, true, btok,
|
||||
[&](const hecl::SystemChar* substr, float factor)
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(msgLock);
|
||||
progress(pakName.c_str(), substr, compIdx, factor);
|
||||
});
|
||||
});
|
||||
progress(sysName.sys_str().c_str(), _S(""), compIdx++, 1.0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user