diff options
| author | 2020-07-18 01:45:10 -0400 | |
|---|---|---|
| committer | 2020-07-18 01:45:10 -0400 | |
| commit | 4a8cb9a70671db5684dadf10061f3c3cf1d27741 (patch) | |
| tree | 76ff712dc903f71245bd6108519b125ca6fac99e /src/core/core_timing.cpp | |
| parent | Merge pull request #4373 from lioncash/allocator (diff) | |
| parent | core_timing: Remove unused data member (diff) | |
| download | yuzu-4a8cb9a70671db5684dadf10061f3c3cf1d27741.tar.gz yuzu-4a8cb9a70671db5684dadf10061f3c3cf1d27741.tar.xz yuzu-4a8cb9a70671db5684dadf10061f3c3cf1d27741.zip | |
Merge pull request #4348 from lioncash/nano
core_timing: Make usage of nanoseconds more consistent in the interface
Diffstat (limited to 'src/core/core_timing.cpp')
| -rw-r--r-- | src/core/core_timing.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index a63e60461..b5feb3f24 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp | |||
| @@ -53,12 +53,12 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) { | |||
| 53 | instance.ThreadLoop(); | 53 | instance.ThreadLoop(); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void CoreTiming::Initialize(std::function<void(void)>&& on_thread_init_) { | 56 | void CoreTiming::Initialize(std::function<void()>&& on_thread_init_) { |
| 57 | on_thread_init = std::move(on_thread_init_); | 57 | on_thread_init = std::move(on_thread_init_); |
| 58 | event_fifo_id = 0; | 58 | event_fifo_id = 0; |
| 59 | shutting_down = false; | 59 | shutting_down = false; |
| 60 | ticks = 0; | 60 | ticks = 0; |
| 61 | const auto empty_timed_callback = [](u64, s64) {}; | 61 | const auto empty_timed_callback = [](u64, std::chrono::nanoseconds) {}; |
| 62 | ev_lost = CreateEvent("_lost_event", empty_timed_callback); | 62 | ev_lost = CreateEvent("_lost_event", empty_timed_callback); |
| 63 | if (is_multicore) { | 63 | if (is_multicore) { |
| 64 | timer_thread = std::make_unique<std::thread>(ThreadEntry, std::ref(*this)); | 64 | timer_thread = std::make_unique<std::thread>(ThreadEntry, std::ref(*this)); |
| @@ -106,11 +106,11 @@ bool CoreTiming::HasPendingEvents() const { | |||
| 106 | return !(wait_set && event_queue.empty()); | 106 | return !(wait_set && event_queue.empty()); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void CoreTiming::ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type, | 109 | void CoreTiming::ScheduleEvent(std::chrono::nanoseconds ns_into_future, |
| 110 | u64 userdata) { | 110 | const std::shared_ptr<EventType>& event_type, u64 userdata) { |
| 111 | { | 111 | { |
| 112 | std::scoped_lock scope{basic_lock}; | 112 | std::scoped_lock scope{basic_lock}; |
| 113 | const u64 timeout = static_cast<u64>(GetGlobalTimeNs().count() + ns_into_future); | 113 | const u64 timeout = static_cast<u64>((GetGlobalTimeNs() + ns_into_future).count()); |
| 114 | 114 | ||
| 115 | event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type}); | 115 | event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type}); |
| 116 | 116 | ||
| @@ -195,8 +195,9 @@ std::optional<s64> CoreTiming::Advance() { | |||
| 195 | event_queue.pop_back(); | 195 | event_queue.pop_back(); |
| 196 | basic_lock.unlock(); | 196 | basic_lock.unlock(); |
| 197 | 197 | ||
| 198 | if (auto event_type{evt.type.lock()}) { | 198 | if (const auto event_type{evt.type.lock()}) { |
| 199 | event_type->callback(evt.userdata, global_timer - evt.time); | 199 | event_type->callback( |
| 200 | evt.userdata, std::chrono::nanoseconds{static_cast<s64>(global_timer - evt.time)}); | ||
| 200 | } | 201 | } |
| 201 | 202 | ||
| 202 | basic_lock.lock(); | 203 | basic_lock.lock(); |