summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 2afb2696c..0e7b5f943 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -41,15 +41,7 @@ CoreTiming::CoreTiming()
: clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {}
CoreTiming::~CoreTiming() {
- paused = true;
- shutting_down = true;
- pause_event.Set();
- event.Set();
- if (timer_thread) {
- timer_thread->join();
- }
- timer_thread.reset();
- has_started = false;
+ Reset();
}
void CoreTiming::ThreadEntry(CoreTiming& instance) {
@@ -63,6 +55,7 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) {
}
void CoreTiming::Initialize(std::function<void()>&& on_thread_init_) {
+ Reset();
on_thread_init = std::move(on_thread_init_);
event_fifo_id = 0;
shutting_down = false;
@@ -304,6 +297,18 @@ void CoreTiming::ThreadLoop() {
}
}
+void CoreTiming::Reset() {
+ paused = true;
+ shutting_down = true;
+ pause_event.Set();
+ event.Set();
+ if (timer_thread) {
+ timer_thread->join();
+ }
+ timer_thread.reset();
+ has_started = false;
+}
+
std::chrono::nanoseconds CoreTiming::GetGlobalTimeNs() const {
if (is_multicore) {
return clock->GetTimeNS();