summaryrefslogtreecommitdiff
path: root/src/core/core_timing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_timing.h')
-rw-r--r--src/core/core_timing.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index d27773009..a86553e08 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -5,6 +5,7 @@
5 5
6#include <atomic> 6#include <atomic>
7#include <chrono> 7#include <chrono>
8#include <condition_variable>
8#include <functional> 9#include <functional>
9#include <memory> 10#include <memory>
10#include <mutex> 11#include <mutex>
@@ -14,7 +15,6 @@
14#include <vector> 15#include <vector>
15 16
16#include "common/common_types.h" 17#include "common/common_types.h"
17#include "common/thread.h"
18#include "common/wall_clock.h" 18#include "common/wall_clock.h"
19 19
20namespace Core::Timing { 20namespace Core::Timing {
@@ -32,6 +32,7 @@ struct EventType {
32 TimedCallback callback; 32 TimedCallback callback;
33 /// A pointer to the name of the event. 33 /// A pointer to the name of the event.
34 const std::string name; 34 const std::string name;
35 mutable std::mutex guard;
35}; 36};
36 37
37/** 38/**
@@ -131,7 +132,7 @@ private:
131 /// Clear all pending events. This should ONLY be done on exit. 132 /// Clear all pending events. This should ONLY be done on exit.
132 void ClearPendingEvents(); 133 void ClearPendingEvents();
133 134
134 static void ThreadEntry(CoreTiming& instance); 135 static void ThreadEntry(CoreTiming& instance, size_t id);
135 void ThreadLoop(); 136 void ThreadLoop();
136 137
137 std::unique_ptr<Common::WallClock> clock; 138 std::unique_ptr<Common::WallClock> clock;
@@ -144,21 +145,25 @@ private:
144 // accomodated by the standard adaptor class. 145 // accomodated by the standard adaptor class.
145 std::vector<Event> event_queue; 146 std::vector<Event> event_queue;
146 u64 event_fifo_id = 0; 147 u64 event_fifo_id = 0;
148 std::atomic<size_t> pending_events{};
147 149
148 std::shared_ptr<EventType> ev_lost; 150 std::shared_ptr<EventType> ev_lost;
149 Common::Event event{};
150 Common::Event pause_event{};
151 std::mutex basic_lock;
152 std::mutex advance_lock;
153 std::unique_ptr<std::thread> timer_thread;
154 std::atomic<bool> paused{};
155 std::atomic<bool> paused_set{};
156 std::atomic<bool> wait_set{};
157 std::atomic<bool> shutting_down{};
158 std::atomic<bool> has_started{}; 151 std::atomic<bool> has_started{};
159 std::function<void()> on_thread_init{}; 152 std::function<void()> on_thread_init{};
160 153
154 std::vector<std::thread> worker_threads;
155
156 std::condition_variable event_cv;
157 std::condition_variable wait_pause_cv;
158 std::condition_variable wait_signal_cv;
159 mutable std::mutex event_mutex;
160 mutable std::mutex sequence_mutex;
161
162 std::atomic<bool> paused_state{};
163 bool is_paused{};
164 bool shutting_down{};
161 bool is_multicore{}; 165 bool is_multicore{};
166 size_t pause_count{};
162 167
163 /// Cycle timing 168 /// Cycle timing
164 u64 ticks{}; 169 u64 ticks{};