diff options
author | Tom <tomut@yahoo.com> | 2020-08-20 09:36:06 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-21 11:47:35 +0200 |
commit | f48feae0b2a300992479abf0b2ded85e45ac6045 (patch) | |
tree | d0b01169a60261135ee15a8d4a6abd01785a7bec /Kernel/Time/TimeManagement.cpp | |
parent | 527c8047fe0a08ade2e17fd096ad9b4ebc103ec5 (diff) | |
download | serenity-f48feae0b2a300992479abf0b2ded85e45ac6045.zip |
Kernel: Switch singletons to use new Singleton class
Fixes #3226
Diffstat (limited to 'Kernel/Time/TimeManagement.cpp')
-rw-r--r-- | Kernel/Time/TimeManagement.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp index d97cf26c46..7982c354b5 100644 --- a/Kernel/Time/TimeManagement.cpp +++ b/Kernel/Time/TimeManagement.cpp @@ -32,6 +32,7 @@ #include <Kernel/Time/HardwareTimer.h> #include <Kernel/Time/PIT.h> #include <Kernel/Time/RTC.h> +#include <Kernel/Singleton.h> #include <Kernel/Time/TimeManagement.h> #include <Kernel/VM/MemoryManager.h> @@ -39,12 +40,11 @@ namespace Kernel { -static TimeManagement* s_time_management; +static auto s_the = make_singleton<TimeManagement>(); TimeManagement& TimeManagement::the() { - ASSERT(s_time_management); - return *s_time_management; + return *s_the; } bool TimeManagement::is_system_timer(const HardwareTimer& timer) const @@ -65,11 +65,9 @@ time_t TimeManagement::epoch_time() const void TimeManagement::initialize() { - ASSERT(!s_time_management); - if (kernel_command_line().lookup("time").value_or("modern") == "legacy") - s_time_management = new TimeManagement(false); - else - s_time_management = new TimeManagement(true); + ASSERT(!s_the.is_initialized()); + s_the.ensure_instance(); + } time_t TimeManagement::seconds_since_boot() const { @@ -90,8 +88,9 @@ time_t TimeManagement::boot_time() const return RTC::boot_time(); } -TimeManagement::TimeManagement(bool probe_non_legacy_hardware_timers) +TimeManagement::TimeManagement() { + bool probe_non_legacy_hardware_timers = !(kernel_command_line().lookup("time").value_or("modern") == "legacy"); if (ACPI::is_enabled()) { if (!ACPI::Parser::the()->x86_specific_flags().cmos_rtc_not_present) { RTC::initialize(); @@ -117,7 +116,8 @@ TimeManagement::TimeManagement(bool probe_non_legacy_hardware_timers) timeval TimeManagement::now_as_timeval() { - return { s_time_management->epoch_time(), (suseconds_t)s_time_management->ticks_this_second() * (suseconds_t)1000 }; + auto* time_management = s_the.ptr(); + return { time_management->epoch_time(), (suseconds_t)time_management->ticks_this_second() * (suseconds_t)1000 }; } Vector<HardwareTimer*> TimeManagement::scan_and_initialize_periodic_timers() |