mirror of https://github.com/axmolengine/axmol.git
commit
babbd64f0d
|
@ -64,6 +64,7 @@ static pthread_mutex_t s_asyncStructQueueMutex;
|
||||||
static pthread_mutex_t s_ImageInfoMutex;
|
static pthread_mutex_t s_ImageInfoMutex;
|
||||||
|
|
||||||
static sem_t s_sem;
|
static sem_t s_sem;
|
||||||
|
static bool need_quit;
|
||||||
|
|
||||||
static std::queue<AsyncStruct*> *s_pAsyncStructQueue;
|
static std::queue<AsyncStruct*> *s_pAsyncStructQueue;
|
||||||
static std::queue<ImageInfo*> *s_pImageQueue;
|
static std::queue<ImageInfo*> *s_pImageQueue;
|
||||||
|
@ -103,6 +104,9 @@ static void* loadImage(void* data)
|
||||||
if (pQueue->empty())
|
if (pQueue->empty())
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&s_asyncStructQueueMutex);
|
pthread_mutex_unlock(&s_asyncStructQueueMutex);
|
||||||
|
if (need_quit)
|
||||||
|
break;
|
||||||
|
else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -171,7 +175,8 @@ CCTextureCache::CCTextureCache()
|
||||||
CCTextureCache::~CCTextureCache()
|
CCTextureCache::~CCTextureCache()
|
||||||
{
|
{
|
||||||
CCLOGINFO("cocos2d: deallocing CCTextureCache.");
|
CCLOGINFO("cocos2d: deallocing CCTextureCache.");
|
||||||
|
need_quit = true;
|
||||||
|
sem_post(&s_sem);
|
||||||
CC_SAFE_RELEASE(m_pTextures);
|
CC_SAFE_RELEASE(m_pTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +236,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
|
||||||
pthread_create(&s_loadingThread, NULL, loadImage, NULL);
|
pthread_create(&s_loadingThread, NULL, loadImage, NULL);
|
||||||
|
|
||||||
CCScheduler::sharedScheduler()->scheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this, 0, false);
|
CCScheduler::sharedScheduler()->scheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this, 0, false);
|
||||||
|
need_quit = false;
|
||||||
firstRun = false;
|
firstRun = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue