2929#include " llwatchdog.h"
3030#include " llthread.h"
3131
32- const U32 WATCHDOG_SLEEP_TIME_USEC = 1000000 ;
32+ constexpr U32 WATCHDOG_SLEEP_TIME_USEC = 1000000U ;
3333
3434// This class runs the watchdog timing thread.
3535class LLWatchdogTimerThread : public LLThread
@@ -51,7 +51,7 @@ class LLWatchdogTimerThread : public LLThread
5151 mSleepMsecs = 1 ;
5252 }
5353
54- /* virtual */ void run ()
54+ void run () override
5555 {
5656 while (!mStopping )
5757 {
@@ -83,7 +83,7 @@ void LLWatchdogEntry::start()
8383void LLWatchdogEntry::stop ()
8484{
8585 // this can happen very late in the shutdown sequence
86- if (! LLWatchdog::wasDeleted ())
86+ if (!LLWatchdog::wasDeleted ())
8787 {
8888 LLWatchdog::getInstance ()->remove (this );
8989 }
@@ -117,7 +117,7 @@ void LLWatchdogTimeout::setTimeout(F32 d)
117117 mTimeout = d;
118118}
119119
120- void LLWatchdogTimeout::start (const std::string& state)
120+ void LLWatchdogTimeout::start (std::string_view state)
121121{
122122 if (mTimeout == 0 )
123123 {
@@ -139,9 +139,9 @@ void LLWatchdogTimeout::stop()
139139 mTimer .stop ();
140140}
141141
142- void LLWatchdogTimeout::ping (const std::string& state)
142+ void LLWatchdogTimeout::ping (std::string_view state)
143143{
144- if (!state.empty ())
144+ if (!state.empty ())
145145 {
146146 mPingState = state;
147147 }
@@ -151,7 +151,7 @@ void LLWatchdogTimeout::ping(const std::string& state)
151151// LLWatchdog
152152LLWatchdog::LLWatchdog ()
153153 :mSuspectsAccessMutex()
154- ,mTimer(NULL )
154+ ,mTimer(nullptr )
155155 ,mLastClockCount(0 )
156156{
157157}
@@ -176,7 +176,7 @@ void LLWatchdog::remove(LLWatchdogEntry* e)
176176
177177void LLWatchdog::init ()
178178{
179- if (!mSuspectsAccessMutex && !mTimer )
179+ if (!mSuspectsAccessMutex && !mTimer )
180180 {
181181 mSuspectsAccessMutex = new LLMutex ();
182182 mTimer = new LLWatchdogTimerThread ();
@@ -191,17 +191,17 @@ void LLWatchdog::init()
191191
192192void LLWatchdog::cleanup ()
193193{
194- if (mTimer )
194+ if (mTimer )
195195 {
196196 mTimer ->stop ();
197197 delete mTimer ;
198- mTimer = NULL ;
198+ mTimer = nullptr ;
199199 }
200200
201- if (mSuspectsAccessMutex )
201+ if (mSuspectsAccessMutex )
202202 {
203203 delete mSuspectsAccessMutex ;
204- mSuspectsAccessMutex = NULL ;
204+ mSuspectsAccessMutex = nullptr ;
205205 }
206206
207207 mLastClockCount = 0 ;
@@ -214,12 +214,12 @@ void LLWatchdog::run()
214214 // Check the time since the last call to run...
215215 // If the time elapsed is two times greater than the regualr sleep time
216216 // reset the active timeouts.
217- const U32 TIME_ELAPSED_MULTIPLIER = 2 ;
217+ constexpr U32 TIME_ELAPSED_MULTIPLIER = 2 ;
218218 U64 current_time = LLTimer::getTotalTime ();
219219 U64 current_run_delta = current_time - mLastClockCount ;
220220 mLastClockCount = current_time;
221221
222- if (current_run_delta > (WATCHDOG_SLEEP_TIME_USEC * TIME_ELAPSED_MULTIPLIER))
222+ if (current_run_delta > (WATCHDOG_SLEEP_TIME_USEC * TIME_ELAPSED_MULTIPLIER))
223223 {
224224 LL_INFOS () << " Watchdog thread delayed: resetting entries." << LL_ENDL;
225225 for (const auto & suspect : mSuspects )
@@ -233,7 +233,7 @@ void LLWatchdog::run()
233233 std::find_if (mSuspects .begin (),
234234 mSuspects .end (),
235235 [](const LLWatchdogEntry* suspect){ return ! suspect->isAlive (); });
236- if (result != mSuspects .end ())
236+ if (result != mSuspects .end ())
237237 {
238238 // error!!!
239239 if (mTimer )
@@ -251,15 +251,15 @@ void LLWatchdog::run()
251251
252252void LLWatchdog::lockThread ()
253253{
254- if (mSuspectsAccessMutex != NULL )
254+ if (mSuspectsAccessMutex )
255255 {
256256 mSuspectsAccessMutex ->lock ();
257257 }
258258}
259259
260260void LLWatchdog::unlockThread ()
261261{
262- if (mSuspectsAccessMutex != NULL )
262+ if (mSuspectsAccessMutex )
263263 {
264264 mSuspectsAccessMutex ->unlock ();
265265 }
0 commit comments