diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2010-03-05 09:15:18 -0700 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2010-03-05 09:15:18 -0700 |
commit | d33b6a18872a652808afe3aa9ae40de6adaa3004 (patch) | |
tree | 6ea0bd6d39110f8cbf8a71c0806c5ca7dfa7f9fc | |
parent | f7ad793e54a0dc4bec53e6ac56b15bb8115620a1 (diff) | |
parent | b0d4919fd453fea9afc1cc0745140e83992997b6 (diff) |
Automated merge with ssh://hg.lindenlab.com/viewer/viewer-2-0/
-rw-r--r-- | indra/llcommon/llworkerthread.cpp | 36 | ||||
-rw-r--r-- | indra/llcommon/llworkerthread.h | 3 | ||||
-rw-r--r-- | indra/newview/llappviewer.cpp | 13 | ||||
-rw-r--r-- | indra/newview/lltexturecache.cpp | 6 | ||||
-rw-r--r-- | indra/newview/lltexturefetch.cpp | 26 | ||||
-rw-r--r-- | indra/newview/lltexturefetch.h | 2 |
6 files changed, 80 insertions, 6 deletions
diff --git a/indra/llcommon/llworkerthread.cpp b/indra/llcommon/llworkerthread.cpp index 1b0e03cb2a..411977474b 100644 --- a/indra/llcommon/llworkerthread.cpp +++ b/indra/llcommon/llworkerthread.cpp @@ -65,6 +65,27 @@ LLWorkerThread::~LLWorkerThread() // ~LLQueuedThread() will be called here } +//called only in destructor. +void LLWorkerThread::clearDeleteList() +{ + // Delete any workers in the delete queue (should be safe - had better be!) + if (!mDeleteList.empty()) + { + llwarns << "Worker Thread: " << mName << " destroyed with " << mDeleteList.size() + << " entries in delete list." << llendl; + + mDeleteMutex->lock(); + for (delete_list_t::iterator iter = mDeleteList.begin(); iter != mDeleteList.end(); ++iter) + { + (*iter)->mRequestHandle = LLWorkerThread::nullHandle(); + (*iter)->clearFlags(LLWorkerClass::WCF_HAVE_WORK); + delete *iter ; + } + mDeleteList.clear() ; + mDeleteMutex->unlock() ; + } +} + // virtual S32 LLWorkerThread::update(U32 max_time_ms) { @@ -320,7 +341,20 @@ bool LLWorkerClass::checkWork(bool aborting) if (mRequestHandle != LLWorkerThread::nullHandle()) { LLWorkerThread::WorkRequest* workreq = (LLWorkerThread::WorkRequest*)mWorkerThread->getRequest(mRequestHandle); - llassert_always(workreq); + if(!workreq) + { + if(mWorkerThread->isQuitting() || mWorkerThread->isStopped()) //the mWorkerThread is not running + { + mRequestHandle = LLWorkerThread::nullHandle(); + clearFlags(WCF_HAVE_WORK); + return true ; + } + else + { + llassert_always(workreq); + } + } + LLQueuedThread::status_t status = workreq->getStatus(); if (status == LLWorkerThread::STATUS_ABORTED) { diff --git a/indra/llcommon/llworkerthread.h b/indra/llcommon/llworkerthread.h index a1e85d2ecc..1756ebab6b 100644 --- a/indra/llcommon/llworkerthread.h +++ b/indra/llcommon/llworkerthread.h @@ -80,6 +80,9 @@ public: S32 mParam; }; +protected: + void clearDeleteList() ; + private: typedef std::list<LLWorkerClass*> delete_list_t; delete_list_t mDeleteList; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6d4c90c2b9..ccd58e26fe 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1516,7 +1516,7 @@ bool LLAppViewer::cleanup() LLAvatarIconIDCache::getInstance()->save(); llinfos << "Shutting down Threads" << llendflush; - + // Let threads finish LLTimer idleTimer; idleTimer.reset(); @@ -1530,19 +1530,26 @@ bool LLAppViewer::cleanup() pending += LLVFSThread::updateClass(0); pending += LLLFSThread::updateClass(0); F64 idle_time = idleTimer.getElapsedTimeF64(); - if (!pending || idle_time >= max_idle_time) + if(!pending) + { + break ; //done + } + else if(idle_time >= max_idle_time) { llwarns << "Quitting with pending background tasks." << llendl; break; } } - + // Delete workers first // shotdown all worker threads before deleting them in case of co-dependencies sTextureCache->shutdown(); sTextureFetch->shutdown(); sImageDecodeThread->shutdown(); + sTextureFetch->shutDownTextureCacheThread() ; + sTextureFetch->shutDownImageDecodeThread() ; + delete sTextureCache; sTextureCache = NULL; delete sTextureFetch; diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 91c303c79e..3116c8feb0 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -750,6 +750,7 @@ LLTextureCache::LLTextureCache(bool threaded) LLTextureCache::~LLTextureCache() { + clearDeleteList() ; } ////////////////////////////////////////////////////////////////////////////// @@ -1574,6 +1575,11 @@ bool LLTextureCache::readComplete(handle_t handle, bool abort) { worker = iter->second; complete = worker->complete(); + + if(!complete && abort) + { + abortRequest(handle, true) ; + } } if (worker && (complete || abort)) { diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 0053ce8df8..b1b3ae473c 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -431,11 +431,11 @@ LLTextureFetchWorker::~LLTextureFetchWorker() // << " Desired=" << mDesiredDiscard << llendl; llassert_always(!haveWork()); lockWorkMutex(); - if (mCacheReadHandle != LLTextureCache::nullHandle()) + if (mCacheReadHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache) { mFetcher->mTextureCache->readComplete(mCacheReadHandle, true); } - if (mCacheWriteHandle != LLTextureCache::nullHandle()) + if (mCacheWriteHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache) { mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true); } @@ -1429,6 +1429,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image LLTextureFetch::~LLTextureFetch() { + clearDeleteList() ; + // ~LLQueuedThread() called here } @@ -1737,6 +1739,26 @@ S32 LLTextureFetch::update(U32 max_time_ms) return res; } +//called in the MAIN thread after the TextureCacheThread shuts down. +void LLTextureFetch::shutDownTextureCacheThread() +{ + if(mTextureCache) + { + llassert_always(mTextureCache->isQuitting() || mTextureCache->isStopped()) ; + mTextureCache = NULL ; + } +} + +//called in the MAIN thread after the ImageDecodeThread shuts down. +void LLTextureFetch::shutDownImageDecodeThread() +{ + if(mImageDecodeThread) + { + llassert_always(mImageDecodeThread->isQuitting() || mImageDecodeThread->isStopped()) ; + mImageDecodeThread = NULL ; + } +} + // WORKER THREAD void LLTextureFetch::startThread() { diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 5213c4f488..ef2ec520bf 100644 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -58,6 +58,8 @@ public: ~LLTextureFetch(); /*virtual*/ S32 update(U32 max_time_ms); + void shutDownTextureCacheThread() ; //called in the main thread after the TextureCacheThread shuts down. + void shutDownImageDecodeThread() ; //called in the main thread after the ImageDecodeThread shuts down. bool createRequest(const std::string& url, const LLUUID& id, const LLHost& host, F32 priority, S32 w, S32 h, S32 c, S32 discard, bool needs_aux); |