Stop threads of texture loading before destroying shader manager
This commit is contained in:
parent
48f2aa3da4
commit
ffd6e84759
@ -574,6 +574,7 @@ void init()
|
|||||||
void destroy()
|
void destroy()
|
||||||
{
|
{
|
||||||
g_dy_dc.clear();
|
g_dy_dc.clear();
|
||||||
|
SPTextureManager::get()->stopThreads();
|
||||||
SPShaderManager::destroy();
|
SPShaderManager::destroy();
|
||||||
g_glow_shader = NULL;
|
g_glow_shader = NULL;
|
||||||
g_normal_visualizer = NULL;
|
g_normal_visualizer = NULL;
|
||||||
|
@ -78,16 +78,7 @@ SPTextureManager::SPTextureManager()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
SPTextureManager::~SPTextureManager()
|
SPTextureManager::~SPTextureManager()
|
||||||
{
|
{
|
||||||
m_max_threaded_load_obj.store(0);
|
assert(m_threaded_load_obj.empty());
|
||||||
std::unique_lock<std::mutex> ul(m_thread_obj_mutex);
|
|
||||||
m_threaded_functions.push_back([](){ return true; });
|
|
||||||
m_thread_obj_cv.notify_all();
|
|
||||||
ul.unlock();
|
|
||||||
for (std::thread& t : m_threaded_load_obj)
|
|
||||||
{
|
|
||||||
t.join();
|
|
||||||
}
|
|
||||||
m_threaded_load_obj.clear();
|
|
||||||
removeUnusedTextures();
|
removeUnusedTextures();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (auto p : m_textures)
|
for (auto p : m_textures)
|
||||||
|
@ -85,6 +85,20 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
~SPTextureManager();
|
~SPTextureManager();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void stopThreads()
|
||||||
|
{
|
||||||
|
m_max_threaded_load_obj.store(0);
|
||||||
|
std::unique_lock<std::mutex> ul(m_thread_obj_mutex);
|
||||||
|
m_threaded_functions.push_back([](){ return true; });
|
||||||
|
m_thread_obj_cv.notify_all();
|
||||||
|
ul.unlock();
|
||||||
|
for (std::thread& t : m_threaded_load_obj)
|
||||||
|
{
|
||||||
|
t.join();
|
||||||
|
}
|
||||||
|
m_threaded_load_obj.clear();
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
void removeUnusedTextures();
|
void removeUnusedTextures();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void addThreadedFunction(std::function<bool()> threaded_function)
|
void addThreadedFunction(std::function<bool()> threaded_function)
|
||||||
|
Loading…
Reference in New Issue
Block a user