Skip to content
Snippets Groups Projects
Commit aaeb8a24 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Revert "Tweak texture decode thread behavior to not choke"

This reverts commit 22d62720.
parent 6af7373a
No related branches found
No related tags found
No related merge requests found
...@@ -35,8 +35,7 @@ std::atomic< U32 > sImageThreads = 0; ...@@ -35,8 +35,7 @@ std::atomic< U32 > sImageThreads = 0;
class PoolWorkerThread final : public LLThread class PoolWorkerThread final : public LLThread
{ {
public: public:
PoolWorkerThread(std::string name) : LLThread(name), PoolWorkerThread(std::string name) : LLThread(name), mRequestQueue(512)
mCurrentRequest(NULL)
{ {
} }
...@@ -44,40 +43,36 @@ class PoolWorkerThread final : public LLThread ...@@ -44,40 +43,36 @@ class PoolWorkerThread final : public LLThread
{ {
while (!isQuitting()) while (!isQuitting())
{ {
auto *pReq = mCurrentRequest.exchange(nullptr); checkPause();
if (pReq) LLImageDecodeThread::ImageRequest* req = nullptr;
pReq->processRequestIntern(); while (!isQuitting() && mRequestQueue.tryPop(req))
checkPause(); {
if (req)
{
req->processRequestIntern();
}
}
} }
} }
bool isBusy()
{
auto *pReq = mCurrentRequest.load();
if (!pReq)
return false;
auto status = pReq->getStatus();
return status == LLQueuedThread::STATUS_QUEUED || status == LLQueuedThread::STATUS_INPROGRESS;
}
bool runCondition() bool runCondition()
{ {
return mCurrentRequest != NULL; return mRequestQueue.size() > 0;
} }
bool setRequest(LLImageDecodeThread::ImageRequest* req) bool setRequest(LLImageDecodeThread::ImageRequest* req)
{ {
LLImageDecodeThread::ImageRequest* pOld{ nullptr }; bool bSuccess = mRequestQueue.tryPush(req);
bool bSuccess = mCurrentRequest.compare_exchange_strong(pOld, req); if(bSuccess)
wake(); {
wake();
}
return bSuccess; return bSuccess;
} }
private: private:
std::atomic<LLImageDecodeThread::ImageRequest*> mCurrentRequest; LLThreadSafeQueue<LLImageDecodeThread::ImageRequest*> mRequestQueue;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -356,7 +351,7 @@ bool LLImageDecodeThread::enqueRequest(ImageRequest * req) ...@@ -356,7 +351,7 @@ bool LLImageDecodeThread::enqueRequest(ImageRequest * req)
mLastPoolAllocation = 0; mLastPoolAllocation = 0;
} }
auto& thread = mThreadPool[mLastPoolAllocation++]; auto& thread = mThreadPool[mLastPoolAllocation++];
if (!thread->isBusy() && thread->setRequest(req)) if (thread->setRequest(req))
{ {
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment