mirror of https://github.com/AxioDL/metaforce.git
Fix TSan-reported race conditions
This commit is contained in:
parent
c3b0e8a241
commit
d2bb3e601b
|
@ -179,8 +179,8 @@ public:
|
|||
specter::FontTag m_curveFont;
|
||||
|
||||
std::thread m_fcacheThread;
|
||||
bool m_fcacheInterrupt = false;
|
||||
bool m_fcacheReady = false;
|
||||
std::atomic_bool m_fcacheInterrupt = {false};
|
||||
std::atomic_bool m_fcacheReady = {false};
|
||||
|
||||
ViewResources() = default;
|
||||
ViewResources(const ViewResources& other) = delete;
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
{
|
||||
if (m_fcacheThread.joinable())
|
||||
{
|
||||
m_fcacheInterrupt = true;
|
||||
m_fcacheInterrupt.store(true);
|
||||
m_fcacheThread.join();
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
void destroyResData();
|
||||
void prepFontCacheSync();
|
||||
void prepFontCacheAsync(boo::IWindow* window);
|
||||
bool fontCacheReady() const { return m_fcacheReady; }
|
||||
bool fontCacheReady() const { return m_fcacheReady.load(); }
|
||||
void resetPixelFactor(float pixelFactor);
|
||||
void resetTheme(const IThemeData* theme);
|
||||
|
||||
|
|
|
@ -58,33 +58,33 @@ void ViewResources::destroyResData()
|
|||
void ViewResources::prepFontCacheSync()
|
||||
{
|
||||
unsigned dpi = 72.f * m_pixelFactor;
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_mainFont = m_fcache->prepMainFont(AllCharFilter, false, 10.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_monoFont10 = m_fcache->prepMonoFont(AllCharFilter, false, 10.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_monoFont18 = m_fcache->prepMonoFont(AllCharFilter, false, 18.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_heading14 = m_fcache->prepMainFont(LatinAndJapaneseCharFilter, false, 14.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_heading18 = m_fcache->prepMainFont(LatinAndJapaneseCharFilter, false, 18.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_titleFont = m_fcache->prepMainFont(LatinCharFilter, false, 36.f, dpi);
|
||||
if (m_fcacheInterrupt)
|
||||
if (m_fcacheInterrupt.load())
|
||||
return;
|
||||
m_fcache->closeBuiltinFonts();
|
||||
m_fcacheReady = true;
|
||||
m_fcacheReady.store(true);
|
||||
}
|
||||
|
||||
void ViewResources::prepFontCacheAsync(boo::IWindow* window)
|
||||
{
|
||||
m_fcacheReady = false;
|
||||
m_fcacheReady.store(false);
|
||||
m_fcacheThread = std::thread([this]() { prepFontCacheSync(); });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue