diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-02-08 17:48:57 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-06-18 22:29:17 +0200 |
commit | 0f8e5a146563d1f245f8f62cb931dc1e0b55de2f (patch) | |
tree | 1145873a1269aca9e259ceb0b14ce946f6f3cbfd /src/core/host_timing.h | |
parent | Core: Implement a Host Timer. (diff) | |
download | yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar.gz yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar.bz2 yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar.lz yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar.xz yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.tar.zst yuzu-0f8e5a146563d1f245f8f62cb931dc1e0b55de2f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/host_timing.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/core/host_timing.h b/src/core/host_timing.h index a3a32e087..1d053a7fa 100644 --- a/src/core/host_timing.h +++ b/src/core/host_timing.h @@ -14,13 +14,15 @@ #include <vector> #include "common/common_types.h" +#include "common/spin_lock.h" +#include "common/thread.h" #include "common/threadsafe_queue.h" namespace Core::HostTiming { /// A callback that may be scheduled for a particular core timing event. using TimedCallback = std::function<void(u64 userdata, s64 cycles_late)>; -using sys_time_point = std::chrono::time_point<std::chrono::system_clock>; +using sys_time_point = std::chrono::time_point<std::chrono::steady_clock>; /// Contains the characteristics of a particular event. struct EventType { @@ -63,6 +65,23 @@ public: /// Tears down all timing related functionality. void Shutdown(); + /// Pauses/Unpauses the execution of the timer thread. + void Pause(bool is_paused); + + /// Pauses/Unpauses the execution of the timer thread and waits until paused. + void SyncPause(bool is_paused); + + /// Checks if core timing is running. + bool IsRunning(); + + /// Checks if the timer thread has started. + bool HasStarted() { + return has_started; + } + + /// Checks if there are any pending time events. + bool HasPendingEvents(); + /// Schedules an event in core timing void ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type, u64 userdata = 0); @@ -107,11 +126,14 @@ private: u64 event_fifo_id = 0; std::shared_ptr<EventType> ev_lost; - bool is_set = false; - std::condition_variable condvar; - std::mutex inner_mutex; + Common::Event event{}; + Common::SpinLock basic_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{}; }; /// Creates a core timing event with the given name and callback. |