diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2021-05-17 13:37:13 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2021-05-17 13:37:13 -0400 |
commit | d313d7021ff551f2a5ef7ec54ff2b3234d96017b (patch) | |
tree | f53604298727a1136ffc5800a65c8cea50706dff /indra/llcommon/llapp.cpp | |
parent | 87faf258911f5d23416500ff632050ce05b30e3e (diff) |
SL-15200: Add LLApp::sleep(duration) methods.
Two sleep() methods: one accepting F32Milliseconds, or in general any LLUnits
time class; the other accepting any std::chrono::duration.
The significant thing about each of these sleep() methods, as opposed to any
freestanding sleep() function, is that it only sleeps until the app starts
shutdown. Moreover, it returns true if it slept for the whole specified
duration, false if it woke for app shutdown.
This is accomplished by making LLApp::sStatus be an LLScalarCond<EAppStatus>
instead of a plain EAppStatus enum, and by making setStatus() call set_all()
each time the value changes. Then each new sleep() method can call
wait_for_unequal(duration, APP_STATUS_RUNNING).
Introducing llcond.h into llapp.h triggered an #include circularity because
llthread.h #included llapp.h even though it didn't reference anything from it.
Removed. This, in turn, necessitated adding #include "llapp.h" to several .cpp
files that reference LLApp but had been depending on other header files to
drag in llapp.h.
Diffstat (limited to 'indra/llcommon/llapp.cpp')
-rw-r--r-- | indra/llcommon/llapp.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index a90b294550..34f6ba140a 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -113,7 +113,8 @@ BOOL LLApp::sDisableCrashlogger = FALSE; BOOL LLApp::sLogInSignal = FALSE; // static -LLApp::EAppStatus LLApp::sStatus = LLApp::APP_STATUS_STOPPED; // Keeps track of application status +// Keeps track of application status +LLScalarCond<LLApp::EAppStatus> LLApp::sStatus{LLApp::APP_STATUS_STOPPED}; LLAppErrorHandler LLApp::sErrorHandler = NULL; BOOL LLApp::sErrorThreadRunning = FALSE; @@ -579,7 +580,8 @@ static std::map<LLApp::EAppStatus, const char*> statusDesc // static void LLApp::setStatus(EAppStatus status) { - sStatus = status; + // notify everyone waiting on sStatus any time its value changes + sStatus.set_all(status); // This can also happen very late in the application lifecycle -- don't // resurrect a deleted LLSingleton @@ -609,6 +611,12 @@ void LLApp::setError() setStatus(APP_STATUS_ERROR); } +// static +bool LLApp::sleep(F32Milliseconds duration) +{ + return ! sStatus.wait_for_unequal(duration, APP_STATUS_RUNNING); +} + void LLApp::setMiniDumpDir(const std::string &path) { if (path.empty()) @@ -668,28 +676,28 @@ void LLApp::setStopped() // static bool LLApp::isStopped() { - return (APP_STATUS_STOPPED == sStatus); + return (APP_STATUS_STOPPED == sStatus.get()); } // static bool LLApp::isRunning() { - return (APP_STATUS_RUNNING == sStatus); + return (APP_STATUS_RUNNING == sStatus.get()); } // static bool LLApp::isError() { - return (APP_STATUS_ERROR == sStatus); + return (APP_STATUS_ERROR == sStatus.get()); } // static bool LLApp::isQuitting() { - return (APP_STATUS_QUITTING == sStatus); + return (APP_STATUS_QUITTING == sStatus.get()); } // static |