diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2021-11-04 16:50:31 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2021-11-04 16:50:31 -0400 |
commit | d848d9e888690210dd37a40c634820fd473699fb (patch) | |
tree | 91403c58f6f6bbae740a7ce0913c4f217d379536 /indra/llrender/llimagegl.cpp | |
parent | 89f2169e9d2c03ed92810689563ca110886abf16 (diff) |
SL-16202: Streamline WorkQueues in LLImageGLThread.
Use the new WorkQueue::postIfOpen() method in LLImageGLThread::post(). That
makes the LLImageGLThread method a trivial wrapper, which can accept templated
work items and pass them through to the WorkQueue method, eliminating double
indirection due to multiple layers of std::function.
Eliminate LLImageGLThread's WorkQueue intended for work on the main queue.
Since the main loop already has a WorkQueue of its own, post work directly to
that WorkQueue instead of using a separate WorkQueue misleadingly embedded in
LLImageGLThread.
Instead of looking up the main thread's WorkQueue every time, capture a
pointer in LLImageGL's constructor.
We no longer need a fallback queue for when the main thread's WorkQueue is
full. We no longer need the main loop to poll LLImageGL to service the local
main-thread-targeted WorkQueue, or to copy work from the fallback queue to the
main queue. That eliminates LLImageGLThread::postCallback(), mCallbackQueue,
mPendingCallbackQ, executeCallbacks() -- and even LLImageGL::updateClass() and
LLAppViewer's call to it.
Change LLViewerFetchedTexture::scheduleCreateTexture() to post work to the
main thread's WorkQueue instead of calling LLImageGLThread::postCallback().
Diffstat (limited to 'indra/llrender/llimagegl.cpp')
-rw-r--r-- | indra/llrender/llimagegl.cpp | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index cbc5392882..71c48801ac 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -183,13 +183,6 @@ void LLImageGL::initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyz LLImageGLThread::sInstance->start(); } -//static -void LLImageGL::updateClass() -{ - LL_PROFILE_ZONE_SCOPED; - LLImageGLThread::sInstance->executeCallbacks(); -} - //static void LLImageGL::cleanupClass() { @@ -504,6 +497,9 @@ void LLImageGL::init(BOOL usemipmaps) #endif mCategory = -1; + + // Sometimes we have to post work for the main thread. + mMainQueue = LL::WorkQueue::getInstance("mainloop"); } void LLImageGL::cleanup() @@ -1554,7 +1550,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ } ref(); - LLImageGLThread::sInstance->postCallback([=]() + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() { LL_PROFILE_ZONE_NAMED("cglt - delete callback"); if (old_texname != 0) @@ -2266,61 +2264,6 @@ LLImageGLThread::LLImageGLThread(LLWindow* window) mContext = mWindow->createSharedContext(); } -// post a function to be executed on the LLImageGL background thread - -bool LLImageGLThread::post(const std::function<void()>& func) -{ - try - { - mFunctionQueue.post(func); - } - catch (LLThreadSafeQueueInterrupt e) - { - return false; - } - - return true; -} - -//post a callback to be executed on the main thread - -bool LLImageGLThread::postCallback(const std::function<void()>& callback) -{ - try - { - if (!mCallbackQueue.tryPost(callback)) - { - mPendingCallbackQ.push(callback); - } - } - catch (LLThreadSafeQueueInterrupt e) - { - //thread is closing, drop request - return false; - } - - return true; -} - -void LLImageGLThread::executeCallbacks() -{ - LL_PROFILE_ZONE_SCOPED; - //executed from main thread - mCallbackQueue.runPending(); - - while (!mPendingCallbackQ.empty()) - { - if (mCallbackQueue.tryPost(mPendingCallbackQ.front())) - { - mPendingCallbackQ.pop(); - } - else - { - break; - } - } -} - void LLImageGLThread::run() { mWindow->makeContextCurrent(mContext); |