* Unregisters the timer and stops processing events for it. */
| 177 | * Unregisters the timer and stops processing events for it. |
| 178 | */ |
| 179 | void Timer::Stop(bool wait) |
| 180 | { |
| 181 | if (l_StopTimerThread) |
| 182 | return; |
| 183 | |
| 184 | std::unique_lock<std::mutex> lock(l_TimerMutex); |
| 185 | |
| 186 | if (m_Started && --l_AliveTimers == 0) { |
| 187 | UninitializeThread(); |
| 188 | } |
| 189 | |
| 190 | m_Started = false; |
| 191 | l_Timers.erase(this); |
| 192 | |
| 193 | /* Notify the worker thread that we've disabled a timer. */ |
| 194 | l_TimerCV.notify_all(); |
| 195 | |
| 196 | while (wait && m_Running) |
| 197 | l_TimerCV.wait(lock); |
| 198 | } |
| 199 | |
| 200 | void Timer::Reschedule(double next) |
| 201 | { |