mirror of https://github.com/axmolengine/axmol.git
assure threading safety
This commit is contained in:
parent
8128bfce68
commit
e3a365ad60
|
@ -143,27 +143,27 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
|
|||
|
||||
void TextureCache::unbindImageAsync(const std::string& filename)
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
if (_imageInfoQueue && !_imageInfoQueue->empty())
|
||||
{
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filename);
|
||||
auto found = std::find_if(_imageInfoQueue->begin(), _imageInfoQueue->end(), [&fullpath](ImageInfo* ptr)->bool{ return ptr->asyncStruct->filename == fullpath; });
|
||||
if (found != _imageInfoQueue->end())
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
(*found)->asyncStruct->callback = nullptr;
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
}
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
|
||||
void TextureCache::unbindAllImageAsync()
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
if (_imageInfoQueue && !_imageInfoQueue->empty())
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
std::for_each(_imageInfoQueue->begin(), _imageInfoQueue->end(), [](ImageInfo* ptr) { ptr->asyncStruct->callback = nullptr; });
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue