Document why Timer::TimerThreadProc() can use Timer members during Timer#~Timer() call

This commit is contained in:
Alexander A. Klimov 2023-03-29 18:04:19 +02:00
parent 66b039df9c
commit 335688909b

View File

@ -296,6 +296,11 @@ void Timer::TimerThreadProc()
break;
auto it = idx.begin();
// timer->~Timer() may be called at any moment (if the last
// smart pointer gets destroyed) or even already waiting for
// l_TimerMutex (before doing anything else) which we have
// locked at the moment. Until our unlock using *timer is safe.
Timer *timer = *it;
ch::time_point<ch::system_clock, ch::duration<double>> next (ch::duration<double>(timer->m_Next));