// Return true if the handle is not valid, which is the case // when the worker was already deleted or is scheduled for deletion. // // If the handle exists and a call to worker->complete() returns // true or abort is true, then the handle is removed and the worker // scheduled for deletion. bool LLTextureCache::readComplete(handle_t handle, bool abort) { lockWorkers(); // Needed for access to mReaders. handle_map_t::iterator iter = mReaders.find(handle); bool handle_is_valid = iter != mReaders.end(); llassert_always(handle_is_valid || abort); LLTextureCacheWorker* worker = NULL; bool delete_worker = false; if (handle_is_valid) { worker = iter->second; delete_worker = worker->complete() || abort; if (delete_worker) { mReaders.erase(handle); handle_is_valid = false; } } unlockWorkers(); if (delete_worker) worker->scheduleDelete(); // Return false if the handle is (still) valid. return !handle_is_valid; }
bool LLTextureCache::writeComplete(handle_t handle, bool abort) { lockWorkers(); handle_map_t::iterator iter = mWriters.find(handle); llassert_always(iter != mWriters.end()); LLTextureCacheWorker* worker = iter->second; if (worker->complete() || abort) { mWriters.erase(handle); unlockWorkers(); worker->scheduleDelete(); return true; } else { unlockWorkers(); return false; } }
//virtual S32 LLTextureCache::update(U32 max_time_ms) { S32 res; res = LLWorkerThread::update(max_time_ms); mListMutex.lock(); handle_list_t priorty_list = mPrioritizeWriteList; // copy list mPrioritizeWriteList.clear(); responder_list_t completed_list = mCompletedList; // copy list mCompletedList.clear(); mListMutex.unlock(); lockWorkers(); for (handle_list_t::iterator iter1 = priorty_list.begin(); iter1 != priorty_list.end(); ++iter1) { handle_t handle = *iter1; handle_map_t::iterator iter2 = mWriters.find(handle); if(iter2 != mWriters.end()) { LLTextureCacheWorker* worker = iter2->second; worker->setPriority(LLWorkerThread::PRIORITY_HIGH | worker->mPriority); } } unlockWorkers(); // call 'completed' with workers list unlocked (may call readComplete() or writeComplete() for (responder_list_t::iterator iter1 = completed_list.begin(); iter1 != completed_list.end(); ++iter1) { Responder *responder = iter1->first; bool success = iter1->second; responder->completed(success); } return res; }