- don't put mutexes into static local variables.

Their initialization semantics are not safe for synchronization objects.
This commit is contained in:
Christoph Oelckers 2018-12-08 11:56:31 +01:00
parent e70138a266
commit 92b722e0ee
3 changed files with 5 additions and 9 deletions

View file

@ -74,6 +74,7 @@ void PolyRenderThread::FlushDrawQueue()
}
}
static std::mutex loadmutex;
void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
{
if (texture == nullptr)
@ -87,8 +88,6 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
// It is critical that this function is called before any direct
// calls to GetPixels for this to work.
static std::mutex loadmutex;
std::unique_lock<std::mutex> lock(loadmutex);
texture->GetPixels(style);
@ -101,10 +100,9 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
}
}
static std::mutex polyobjmutex;
void PolyRenderThread::PreparePolyObject(subsector_t *sub)
{
static std::mutex polyobjmutex;
std::unique_lock<std::mutex> lock(polyobjmutex);
if (sub->BSP == nullptr || sub->BSP->bDirty)

View file

@ -89,6 +89,7 @@ namespace swrenderer
return pal_drawers.get();
}
static std::mutex loadmutex;
void RenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
{
if (texture == nullptr)
@ -102,8 +103,6 @@ namespace swrenderer
// It is critical that this function is called before any direct
// calls to GetPixels for this to work.
static std::mutex loadmutex;
std::unique_lock<std::mutex> lock(loadmutex);
texture->GetPixels(style);
@ -116,10 +115,9 @@ namespace swrenderer
}
}
static std::mutex polyobjmutex;
void RenderThread::PreparePolyObject(subsector_t *sub)
{
static std::mutex polyobjmutex;
std::unique_lock<std::mutex> lock(polyobjmutex);
if (sub->BSP == nullptr || sub->BSP->bDirty)

View file

@ -70,12 +70,12 @@ TArray<FSWColormap> SpecialSWColormaps;
// Colored Lighting Stuffs
//
//==========================================================================
static std::mutex buildmapmutex;
static FDynamicColormap *CreateSpecialLights (PalEntry color, PalEntry fade, int desaturate)
{
// GetSpecialLights is called by the scene worker threads.
// If we didn't find the colormap, search again, but this time one thread at a time
static std::mutex buildmapmutex;
std::unique_lock<std::mutex> lock(buildmapmutex);
// If this colormap has already been created, just return it