Merge pull request #4079 from zhaowenlan1779/port-yuzu-932
Port "core_timing: Use transparent functors where applicable" from yuzu
This commit is contained in:
commit
4aec7ec96b
|
@ -142,7 +142,7 @@ void ScheduleEvent(s64 cycles_into_future, const EventType* event_type, u64 user
|
||||||
ForceExceptionCheck(cycles_into_future);
|
ForceExceptionCheck(cycles_into_future);
|
||||||
|
|
||||||
event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type});
|
event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type});
|
||||||
std::push_heap(event_queue.begin(), event_queue.end(), std::greater<Event>());
|
std::push_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleEventThreadsafe(s64 cycles_into_future, const EventType* event_type, u64 userdata) {
|
void ScheduleEventThreadsafe(s64 cycles_into_future, const EventType* event_type, u64 userdata) {
|
||||||
|
@ -157,7 +157,7 @@ void UnscheduleEvent(const EventType* event_type, u64 userdata) {
|
||||||
// Removing random items breaks the invariant so we have to re-establish it.
|
// Removing random items breaks the invariant so we have to re-establish it.
|
||||||
if (itr != event_queue.end()) {
|
if (itr != event_queue.end()) {
|
||||||
event_queue.erase(itr, event_queue.end());
|
event_queue.erase(itr, event_queue.end());
|
||||||
std::make_heap(event_queue.begin(), event_queue.end(), std::greater<Event>());
|
std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ void RemoveEvent(const EventType* event_type) {
|
||||||
// Removing random items breaks the invariant so we have to re-establish it.
|
// Removing random items breaks the invariant so we have to re-establish it.
|
||||||
if (itr != event_queue.end()) {
|
if (itr != event_queue.end()) {
|
||||||
event_queue.erase(itr, event_queue.end());
|
event_queue.erase(itr, event_queue.end());
|
||||||
std::make_heap(event_queue.begin(), event_queue.end(), std::greater<Event>());
|
std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ void MoveEvents() {
|
||||||
for (Event ev; ts_queue.Pop(ev);) {
|
for (Event ev; ts_queue.Pop(ev);) {
|
||||||
ev.fifo_order = event_fifo_id++;
|
ev.fifo_order = event_fifo_id++;
|
||||||
event_queue.emplace_back(std::move(ev));
|
event_queue.emplace_back(std::move(ev));
|
||||||
std::push_heap(event_queue.begin(), event_queue.end(), std::greater<Event>());
|
std::push_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ void Advance() {
|
||||||
|
|
||||||
while (!event_queue.empty() && event_queue.front().time <= global_timer) {
|
while (!event_queue.empty() && event_queue.front().time <= global_timer) {
|
||||||
Event evt = std::move(event_queue.front());
|
Event evt = std::move(event_queue.front());
|
||||||
std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<Event>());
|
std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
event_queue.pop_back();
|
event_queue.pop_back();
|
||||||
evt.type->callback(evt.userdata, global_timer - evt.time);
|
evt.type->callback(evt.userdata, global_timer - evt.time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,10 @@ inline u64 cyclesToMs(s64 cycles) {
|
||||||
|
|
||||||
namespace CoreTiming {
|
namespace CoreTiming {
|
||||||
|
|
||||||
|
struct EventType;
|
||||||
|
|
||||||
|
using TimedCallback = std::function<void(u64 userdata, int cycles_late)>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is
|
* CoreTiming begins at the boundary of timing slice -1. An initial call to Advance() is
|
||||||
* required to end slice -1 and start slice 0 before the first cycle of code is executed.
|
* required to end slice -1 and start slice 0 before the first cycle of code is executed.
|
||||||
|
@ -128,8 +132,6 @@ namespace CoreTiming {
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
typedef std::function<void(u64 userdata, s64 cycles_late)> TimedCallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should only be called from the emu thread, if you are calling it any other thread, you are
|
* This should only be called from the emu thread, if you are calling it any other thread, you are
|
||||||
* doing something evil
|
* doing something evil
|
||||||
|
@ -138,8 +140,6 @@ u64 GetTicks();
|
||||||
u64 GetIdleTicks();
|
u64 GetIdleTicks();
|
||||||
void AddTicks(u64 ticks);
|
void AddTicks(u64 ticks);
|
||||||
|
|
||||||
struct EventType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the event_type identifier. if name is not unique, it will assert.
|
* Returns the event_type identifier. if name is not unique, it will assert.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue