summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-05-31 16:54:05 -0500
committerDave Parks <davep@lindenlab.com>2022-05-31 16:54:05 -0500
commitfc7b5549cb6092194d11b8d87600f21992305c1c (patch)
tree40ef1776b4abd77405c60d64043f5782dfc3e4be /indra/llcommon
parentdfa71e2bb59e81de93f626fada6975ae46b01bb6 (diff)
SL-17484 Fix for unit tests. Deprecate non-threaded LLQueuedThread and make lllfsthread threaded.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llqueuedthread.cpp23
-rw-r--r--indra/llcommon/lltimer.cpp7
2 files changed, 20 insertions, 10 deletions
diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp
index 871c42f7ee..60304fff75 100644
--- a/indra/llcommon/llqueuedthread.cpp
+++ b/indra/llcommon/llqueuedthread.cpp
@@ -37,12 +37,13 @@
// MAIN THREAD
LLQueuedThread::LLQueuedThread(const std::string& name, bool threaded, bool should_pause) :
LLThread(name),
- mThreaded(threaded),
mIdleThread(TRUE),
mNextHandle(0),
mStarted(FALSE),
+ mThreaded(threaded),
mRequestQueue(name, 1024 * 1024)
{
+ llassert(threaded); // not threaded implementation is deprecated
mMainQueue = LL::WorkQueue::getInstance("mainloop");
if (mThreaded)
@@ -138,14 +139,18 @@ S32 LLQueuedThread::updateQueue(F32 max_time_ms)
if (mThreaded)
{
// schedule a call to threadedUpdate for every call to updateQueue
- mRequestQueue.post([=]()
- {
- LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update");
- mIdleThread = FALSE;
- threadedUpdate();
- mIdleThread = TRUE;
- }
- );
+ if (!isQuitting())
+ {
+ mRequestQueue.post([=]()
+ {
+ LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update");
+ mIdleThread = FALSE;
+ threadedUpdate();
+ mIdleThread = TRUE;
+ }
+ );
+ }
+
if(getPending() > 0)
{
unpause();
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 466f98f9b2..39dfee3755 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -68,7 +68,12 @@ LLTimer* LLTimer::sTimer = NULL;
void ms_sleep(U32 ms)
{
LL_PROFILE_ZONE_SCOPED;
- std::this_thread::sleep_for(std::chrono::microseconds(ms));
+ using TimePoint = std::chrono::steady_clock::time_point;
+ auto resume_time = TimePoint::clock::now() + std::chrono::milliseconds(ms);
+ while (TimePoint::clock::now() < resume_time)
+ {
+ std::this_thread::yield(); //note: don't use LLThread::yield here to avoid yielding for too long
+ }
}
U32 micro_sleep(U64 us, U32 max_yields)