Wrap sGlobalRawMemory in AIThreadSafe.

This is accessed by different threads.
Other globals like it might also be
accessed by different threads, this has
to be investigated.
This commit is contained in:
Aleric Inglewood
2011-08-05 00:05:08 +02:00
parent 20d2012fc3
commit 881d065220
5 changed files with 25 additions and 10 deletions

View File

@@ -246,7 +246,7 @@ U8* LLImageBase::allocateDataSize(S32 width, S32 height, S32 ncomponents, S32 si
// LLImageRaw
//---------------------------------------------------------------------------
S32 LLImageRaw::sGlobalRawMemory = 0;
AITHREADSAFESIMPLE(S32, LLImageRaw::sGlobalRawMemory, );
S32 LLImageRaw::sRawImageCount = 0;
S32 LLImageRaw::sRawImageCachedCount = 0;
@@ -296,23 +296,25 @@ LLImageRaw::~LLImageRaw()
U8* LLImageRaw::allocateData(S32 size)
{
U8* res = LLImageBase::allocateData(size);
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize();
return res;
}
// virtual
U8* LLImageRaw::reallocateData(S32 size)
{
sGlobalRawMemory -= getDataSize();
S32 old_data_size = getDataSize();
U8* res = LLImageBase::reallocateData(size);
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize() - old_data_size;
return res;
}
// virtual
void LLImageRaw::deleteData()
{
sGlobalRawMemory -= getDataSize();
{
*AIAccess<S32>(sGlobalRawMemory) -= getDataSize();
}
LLImageBase::deleteData();
}
@@ -328,7 +330,7 @@ void LLImageRaw::setDataAndSize(U8 *data, S32 width, S32 height, S8 components)
LLImageBase::setSize(width, height, components) ;
LLImageBase::setDataAndSize(data, width * height * components) ;
sGlobalRawMemory += getDataSize();
*AIAccess<S32>(sGlobalRawMemory) += getDataSize();
}
BOOL LLImageRaw::resize(U16 width, U16 height, S8 components)