From 0f4861cac2138211bc322852686dc49033403f06 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 26 Aug 2015 14:53:58 +0200 Subject: [PATCH 1/2] CoreTiming: make loops easier to read --- Source/Core/Core/CoreTiming.cpp | 39 ++++++++++----------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index e52d49cbe548..deaae43830cb 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -324,21 +324,11 @@ bool IsScheduled(int event_type) void RemoveEvent(int event_type) { - if (!first) - return; - - while (first) + while (first && first->type == event_type) { - if (first->type == event_type) - { - Event *next = first->next; - FreeEvent(first); - first = next; - } - else - { - break; - } + Event* next = first->next; + FreeEvent(first); + first = next; } if (!first) @@ -434,21 +424,14 @@ void Advance() lastOCFactor = SConfig::GetInstance().m_OCEnable ? SConfig::GetInstance().m_OCFactor : 1.0f; PowerPC::ppcState.downcount = CyclesToDowncount(slicelength); - while (first) + while (first && first->time <= globalTimer) { - if (first->time <= globalTimer) - { - //LOG(POWERPC, "[Scheduler] %s (%lld, %lld) ", - // event_types[first->type].name ? event_types[first->type].name : "?", (u64)globalTimer, (u64)first->time); - Event* evt = first; - first = first->next; - event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); - FreeEvent(evt); - } - else - { - break; - } + //LOG(POWERPC, "[Scheduler] %s (%lld, %lld) ", + // event_types[first->type].name ? event_types[first->type].name : "?", (u64)globalTimer, (u64)first->time); + Event* evt = first; + first = first->next; + event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); + FreeEvent(evt); } if (!first) From 6ec4bdf862af33ea76298b7e9a99a66456d00f28 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 26 Aug 2015 15:40:15 +0200 Subject: [PATCH 2/2] CoreTiming: remove unused functions --- Source/Core/Core/CoreTiming.cpp | 35 --------------------------------- Source/Core/Core/CoreTiming.h | 5 ----- 2 files changed, 40 deletions(-) diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index deaae43830cb..a8f8667e371b 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -63,9 +63,6 @@ u64 fakeTBStartTicks; static int ev_lost; - -static void (*advanceCallback)(int cyclesExecuted) = nullptr; - static Event* GetNewEvent() { if (!eventPool) @@ -303,25 +300,6 @@ void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata) AddEventToQueue(ne); } -void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted)) -{ - advanceCallback = callback; -} - -bool IsScheduled(int event_type) -{ - if (!first) - return false; - Event *e = first; - while (e) - { - if (e->type == event_type) - return true; - e = e->next; - } - return false; -} - void RemoveEvent(int event_type) { while (first && first->type == event_type) @@ -358,11 +336,6 @@ void RemoveAllEvents(int event_type) RemoveEvent(event_type); } -void SetMaximumSlice(int maximumSliceLength) -{ - maxSliceLength = maximumSliceLength; -} - void ForceExceptionCheck(int cycles) { if (DowncountToCycles(PowerPC::ppcState.downcount) > cycles) @@ -372,11 +345,6 @@ void ForceExceptionCheck(int cycles) } } -void ResetSliceLength() -{ - maxSliceLength = MAX_SLICE_LENGTH; -} - //This raise only the events required while the fifo is processing data void ProcessFifoWaitEvents() @@ -446,9 +414,6 @@ void Advance() slicelength = maxSliceLength; PowerPC::ppcState.downcount = CyclesToDowncount(slicelength); } - - if (advanceCallback) - advanceCallback(cyclesExecuted); } void LogPendingEvents() diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 69d92871aed6..236df4723143 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -52,7 +52,6 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata = 0); // We only permit one event of each type in the queue at a time. void RemoveEvent(int event_type); void RemoveAllEvents(int event_type); -bool IsScheduled(int event_type); void Advance(); void MoveEvents(); void ProcessFifoWaitEvents(); @@ -64,10 +63,6 @@ void Idle(); void ClearPendingEvents(); void LogPendingEvents(); -void SetMaximumSlice(int maximumSliceLength); -void ResetSliceLength(); - -void RegisterAdvanceCallback(void (*callback)(int cyclesExecuted)); std::string GetScheduledEventsSummary();