Serialize core timing

This commit is contained in:
Hamish Milne
2020-01-12 20:01:29 +00:00
committed by zhupengfei
parent 8abc5525be
commit c24ea0f0ee
5 changed files with 54 additions and 3 deletions

View File

@ -11,6 +11,8 @@
namespace Core {
Timing* Timing::deserializing = nullptr;
// Sort by time, unless the times are the same, in which case sort by the order added to the queue
bool Timing::Event::operator>(const Event& right) const {
return std::tie(time, fifo_order) > std::tie(right.time, right.fifo_order);
@ -26,7 +28,9 @@ TimingEventType* Timing::RegisterEvent(const std::string& name, TimedCallback ca
auto info = event_types.emplace(name, TimingEventType{});
TimingEventType* event_type = &info.first->second;
event_type->name = &info.first->first;
event_type->callback = callback;
if (callback != nullptr) {
event_type->callback = callback;
}
return event_type;
}
@ -129,7 +133,9 @@ void Timing::Advance() {
LOG_ERROR(Core, "Unknown queued event");
continue;
}
evt.type->callback(evt.userdata, global_timer - evt.time);
if (evt.type->callback != nullptr) {
evt.type->callback(evt.userdata, global_timer - evt.time);
}
}
is_global_timer_sane = false;