Merge pull request #9738 from Icinga/TimerThreadProc

Document why Timer::TimerThreadProc() can use Timer members during Timer#~Timer() call
This commit is contained in:
Julian Brost 2023-03-30 16:03:43 +02:00 committed by GitHub
commit 1665cc925e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -296,6 +296,11 @@ void Timer::TimerThreadProc()
break; break;
auto it = idx.begin(); 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; Timer *timer = *it;
ch::time_point<ch::system_clock, ch::duration<double>> next (ch::duration<double>(timer->m_Next)); ch::time_point<ch::system_clock, ch::duration<double>> next (ch::duration<double>(timer->m_Next));