diff options
| author | 2020-07-15 19:14:21 -0400 | |
|---|---|---|
| committer | 2020-07-15 19:41:22 -0400 | |
| commit | bef1844a51a37c1c8dc531e67069ef00821ffa9c (patch) | |
| tree | 2e46f404c3f0baf1b854e1bea916c19469fe424a /src/core/core_timing.h | |
| parent | core_timing: Make use of std::chrono with ScheduleEvent (diff) | |
| download | yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.gz yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.xz yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.zip | |
core_timing: Make TimedCallback take std::chrono::nanoseconds
Enforces our desired time units directly with a concrete type.
Diffstat (limited to 'src/core/core_timing.h')
| -rw-r--r-- | src/core/core_timing.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h index 9b9f18daf..a21356a08 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h | |||
| @@ -17,14 +17,12 @@ | |||
| 17 | #include "common/common_types.h" | 17 | #include "common/common_types.h" |
| 18 | #include "common/spin_lock.h" | 18 | #include "common/spin_lock.h" |
| 19 | #include "common/thread.h" | 19 | #include "common/thread.h" |
| 20 | #include "common/threadsafe_queue.h" | ||
| 21 | #include "common/wall_clock.h" | 20 | #include "common/wall_clock.h" |
| 22 | #include "core/hardware_properties.h" | ||
| 23 | 21 | ||
| 24 | namespace Core::Timing { | 22 | namespace Core::Timing { |
| 25 | 23 | ||
| 26 | /// A callback that may be scheduled for a particular core timing event. | 24 | /// A callback that may be scheduled for a particular core timing event. |
| 27 | using TimedCallback = std::function<void(u64 userdata, s64 cycles_late)>; | 25 | using TimedCallback = std::function<void(u64 userdata, std::chrono::nanoseconds ns_late)>; |
| 28 | 26 | ||
| 29 | /// Contains the characteristics of a particular event. | 27 | /// Contains the characteristics of a particular event. |
| 30 | struct EventType { | 28 | struct EventType { |
| @@ -42,12 +40,12 @@ struct EventType { | |||
| 42 | * in main CPU clock cycles. | 40 | * in main CPU clock cycles. |
| 43 | * | 41 | * |
| 44 | * To schedule an event, you first have to register its type. This is where you pass in the | 42 | * To schedule an event, you first have to register its type. This is where you pass in the |
| 45 | * callback. You then schedule events using the type id you get back. | 43 | * callback. You then schedule events using the type ID you get back. |
| 46 | * | 44 | * |
| 47 | * The int cyclesLate that the callbacks get is how many cycles late it was. | 45 | * The s64 ns_late that the callbacks get is how many ns late it was. |
| 48 | * So to schedule a new event on a regular basis: | 46 | * So to schedule a new event on a regular basis: |
| 49 | * inside callback: | 47 | * inside callback: |
| 50 | * ScheduleEvent(periodInCycles - cyclesLate, callback, "whatever") | 48 | * ScheduleEvent(period_in_ns - ns_late, callback, "whatever") |
| 51 | */ | 49 | */ |
| 52 | class CoreTiming { | 50 | class CoreTiming { |
| 53 | public: | 51 | public: |