diff options
author | Fernando S <fsahmkow27@gmail.com> | 2022-06-30 12:38:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 12:38:50 +0200 |
commit | 603952bc27aca2e17d39def7710d9af36791f15c (patch) | |
tree | 8b6b2f943bbf2fc749dbe144eee26cd144c084c9 /src/core/core_timing.h | |
parent | 4ef66ec8fbb8c863db9063fe2bd332f22a5748ee (diff) | |
parent | 3196d957b02266293b68a60c75c3db9a00faf1f6 (diff) |
Merge pull request #7454 from FernandoS27/new-core-timing
Core: Remake Core Timing
Diffstat (limited to 'src/core/core_timing.h')
-rw-r--r-- | src/core/core_timing.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h index d277730096..a86553e08b 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -5,6 +5,7 @@ #include <atomic> #include <chrono> +#include <condition_variable> #include <functional> #include <memory> #include <mutex> @@ -14,7 +15,6 @@ #include <vector> #include "common/common_types.h" -#include "common/thread.h" #include "common/wall_clock.h" namespace Core::Timing { @@ -32,6 +32,7 @@ struct EventType { TimedCallback callback; /// A pointer to the name of the event. const std::string name; + mutable std::mutex guard; }; /** @@ -131,7 +132,7 @@ private: /// Clear all pending events. This should ONLY be done on exit. void ClearPendingEvents(); - static void ThreadEntry(CoreTiming& instance); + static void ThreadEntry(CoreTiming& instance, size_t id); void ThreadLoop(); std::unique_ptr<Common::WallClock> clock; @@ -144,21 +145,25 @@ private: // accomodated by the standard adaptor class. std::vector<Event> event_queue; u64 event_fifo_id = 0; + std::atomic<size_t> pending_events{}; std::shared_ptr<EventType> ev_lost; - Common::Event event{}; - Common::Event pause_event{}; - std::mutex basic_lock; - std::mutex advance_lock; - std::unique_ptr<std::thread> timer_thread; - std::atomic<bool> paused{}; - std::atomic<bool> paused_set{}; - std::atomic<bool> wait_set{}; - std::atomic<bool> shutting_down{}; std::atomic<bool> has_started{}; std::function<void()> on_thread_init{}; + std::vector<std::thread> worker_threads; + + std::condition_variable event_cv; + std::condition_variable wait_pause_cv; + std::condition_variable wait_signal_cv; + mutable std::mutex event_mutex; + mutable std::mutex sequence_mutex; + + std::atomic<bool> paused_state{}; + bool is_paused{}; + bool shutting_down{}; bool is_multicore{}; + size_t pause_count{}; /// Cycle timing u64 ticks{}; |