mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-06 00:37:26 +00:00
chore: add define for not loading xchunks async
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#define XCHUNK_ASYNC 1
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class DbLoadStream
|
class DbLoadStream
|
||||||
@@ -44,17 +46,24 @@ namespace
|
|||||||
{
|
{
|
||||||
if (inputSize > 0)
|
if (inputSize > 0)
|
||||||
{
|
{
|
||||||
|
#ifdef XCHUNK_ASYNC
|
||||||
std::unique_lock lock(m_load_mutex);
|
std::unique_lock lock(m_load_mutex);
|
||||||
|
|
||||||
if (m_is_loading)
|
if (m_is_loading)
|
||||||
{
|
{
|
||||||
m_loading_finished.wait(lock);
|
m_loading_finished.wait(lock);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_input_size = inputSize;
|
m_input_size = inputSize;
|
||||||
m_is_loading = true;
|
m_is_loading = true;
|
||||||
|
|
||||||
|
#ifdef XCHUNK_ASYNC
|
||||||
m_load_thread = std::thread(&DbLoadStream::Load, this);
|
m_load_thread = std::thread(&DbLoadStream::Load, this);
|
||||||
m_load_thread.detach();
|
m_load_thread.detach();
|
||||||
|
#else
|
||||||
|
Load();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -80,7 +89,9 @@ namespace
|
|||||||
private:
|
private:
|
||||||
void Load()
|
void Load()
|
||||||
{
|
{
|
||||||
|
#ifdef XCHUNK_ASYNC
|
||||||
std::lock_guard lock(m_load_mutex);
|
std::lock_guard lock(m_load_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool firstProcessor = true;
|
bool firstProcessor = true;
|
||||||
|
|
||||||
@@ -102,7 +113,10 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_is_loading = false;
|
m_is_loading = false;
|
||||||
|
|
||||||
|
#ifdef XCHUNK_ASYNC
|
||||||
m_loading_finished.notify_all();
|
m_loading_finished.notify_all();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int m_index;
|
int m_index;
|
||||||
|
Reference in New Issue
Block a user