Turn the default Timer in PeriodicTaskScheduler into a leaky Meyers singleton (#12128)

Summary:
Pull Request resolved: https://github.com/facebook/rocksdb/pull/12128

The patch turns the `Timer` Meyers singleton in `PeriodicTaskScheduler::Default()` into one of the leaky variety in order to prevent static destruction order issues.

Reviewed By: akankshamahajan15

Differential Revision: D51963950

fbshipit-source-id: 0fc34113ad03c51fdc83bdb8c2cfb6c9f6913948
This commit is contained in:
Levi Tamasi 2023-12-08 10:34:07 -08:00 committed by Facebook GitHub Bot
parent 179d2c7646
commit a143f93236
2 changed files with 2 additions and 2 deletions

View File

@ -94,7 +94,7 @@ Status PeriodicTaskScheduler::Unregister(PeriodicTaskType task_type) {
} }
Timer* PeriodicTaskScheduler::Default() { Timer* PeriodicTaskScheduler::Default() {
static Timer timer(SystemClock::Default().get()); STATIC_AVOID_DESTRUCTION(Timer, timer)(SystemClock::Default().get());
return &timer; return &timer;
} }
@ -108,4 +108,3 @@ void PeriodicTaskScheduler::TEST_OverrideTimer(SystemClock* clock) {
#endif // NDEBUG #endif // NDEBUG
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

View File

@ -0,0 +1 @@
Avoid destroying the periodic task scheduler's default timer in order to prevent static destruction order issues.