core_timing: Make TimedCallback take std::chrono::nanoseconds

Enforces our desired time units directly with a concrete type.
This commit is contained in:
Lioncash 2020-07-15 19:14:21 -04:00
parent 9e113a2b67
commit 56054fe86d
16 changed files with 62 additions and 58 deletions

View file

@ -58,7 +58,7 @@ void CoreTiming::Initialize(std::function<void()>&& on_thread_init_) {
event_fifo_id = 0;
shutting_down = false;
ticks = 0;
const auto empty_timed_callback = [](u64, s64) {};
const auto empty_timed_callback = [](u64, std::chrono::nanoseconds) {};
ev_lost = CreateEvent("_lost_event", empty_timed_callback);
if (is_multicore) {
timer_thread = std::make_unique<std::thread>(ThreadEntry, std::ref(*this));
@ -195,8 +195,9 @@ std::optional<s64> CoreTiming::Advance() {
event_queue.pop_back();
basic_lock.unlock();
if (auto event_type{evt.type.lock()}) {
event_type->callback(evt.userdata, global_timer - evt.time);
if (const auto event_type{evt.type.lock()}) {
event_type->callback(
evt.userdata, std::chrono::nanoseconds{static_cast<s64>(global_timer - evt.time)});
}
basic_lock.lock();