diff options
author | Alex Barney <thealexbarney@gmail.com> | 2018-12-04 14:23:37 -0600 |
---|---|---|
committer | gdkchan <gab.dark.100@gmail.com> | 2018-12-04 18:23:37 -0200 |
commit | 85dbb9559ad317a657dafd24da27fec4b3f5250f (patch) | |
tree | ecd92931bc2146e549484d9a3af308469089ad4e /Ryujinx.HLE/HOS/Kernel/HleScheduler.cs | |
parent | c86aacde76b5f8e503e2b412385c8491ecc86b3b (diff) |
Adjust naming conventions and general refactoring in HLE Project (#490)
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787cc5b27a4631cd46ef5f551c4ae95e51.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Remove unneeded property setters
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/HleScheduler.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/HleScheduler.cs | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/HleScheduler.cs b/Ryujinx.HLE/HOS/Kernel/HleScheduler.cs index 87dbe553..4afc48ba 100644 --- a/Ryujinx.HLE/HOS/Kernel/HleScheduler.cs +++ b/Ryujinx.HLE/HOS/Kernel/HleScheduler.cs @@ -7,21 +7,21 @@ namespace Ryujinx.HLE.HOS.Kernel { private const int RoundRobinTimeQuantumMs = 10; - private int CurrentCore; + private int _currentCore; public bool MultiCoreScheduling { get; set; } - public HleCoreManager CoreManager { get; private set; } + public HleCoreManager CoreManager { get; } - private bool KeepPreempting; + private bool _keepPreempting; public void StartAutoPreemptionThread() { - Thread PreemptionThread = new Thread(PreemptCurrentThread); + Thread preemptionThread = new Thread(PreemptCurrentThread); - KeepPreempting = true; + _keepPreempting = true; - PreemptionThread.Start(); + preemptionThread.Start(); } public void ContextSwitch() @@ -30,28 +30,28 @@ namespace Ryujinx.HLE.HOS.Kernel { if (MultiCoreScheduling) { - int SelectedCount = 0; + int selectedCount = 0; - for (int Core = 0; Core < KScheduler.CpuCoresCount; Core++) + for (int core = 0; core < CpuCoresCount; core++) { - KCoreContext CoreContext = CoreContexts[Core]; + KCoreContext coreContext = CoreContexts[core]; - if (CoreContext.ContextSwitchNeeded && (CoreContext.CurrentThread?.Context.IsCurrentThread() ?? false)) + if (coreContext.ContextSwitchNeeded && (coreContext.CurrentThread?.Context.IsCurrentThread() ?? false)) { - CoreContext.ContextSwitch(); + coreContext.ContextSwitch(); } - if (CoreContext.CurrentThread?.Context.IsCurrentThread() ?? false) + if (coreContext.CurrentThread?.Context.IsCurrentThread() ?? false) { - SelectedCount++; + selectedCount++; } } - if (SelectedCount == 0) + if (selectedCount == 0) { CoreManager.Reset(Thread.CurrentThread); } - else if (SelectedCount == 1) + else if (selectedCount == 1) { CoreManager.Set(Thread.CurrentThread); } @@ -62,41 +62,41 @@ namespace Ryujinx.HLE.HOS.Kernel } else { - KThread CurrentThread = CoreContexts[CurrentCore].CurrentThread; + KThread currentThread = CoreContexts[_currentCore].CurrentThread; - bool HasThreadExecuting = CurrentThread != null; + bool hasThreadExecuting = currentThread != null; - if (HasThreadExecuting) + if (hasThreadExecuting) { //If this is not the thread that is currently executing, we need //to request an interrupt to allow safely starting another thread. - if (!CurrentThread.Context.IsCurrentThread()) + if (!currentThread.Context.IsCurrentThread()) { - CurrentThread.Context.RequestInterrupt(); + currentThread.Context.RequestInterrupt(); return; } - CoreManager.Reset(CurrentThread.Context.Work); + CoreManager.Reset(currentThread.Context.Work); } //Advance current core and try picking a thread, //keep advancing if it is null. - for (int Core = 0; Core < 4; Core++) + for (int core = 0; core < 4; core++) { - CurrentCore = (CurrentCore + 1) % CpuCoresCount; + _currentCore = (_currentCore + 1) % CpuCoresCount; - KCoreContext CoreContext = CoreContexts[CurrentCore]; + KCoreContext coreContext = CoreContexts[_currentCore]; - CoreContext.UpdateCurrentThread(); + coreContext.UpdateCurrentThread(); - if (CoreContext.CurrentThread != null) + if (coreContext.CurrentThread != null) { - CoreContext.CurrentThread.ClearExclusive(); + coreContext.CurrentThread.ClearExclusive(); - CoreManager.Set(CoreContext.CurrentThread.Context.Work); + CoreManager.Set(coreContext.CurrentThread.Context.Work); - CoreContext.CurrentThread.Context.Execute(); + coreContext.CurrentThread.Context.Execute(); break; } @@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Kernel //If nothing was running before, then we are on a "external" //HLE thread, we don't need to wait. - if (!HasThreadExecuting) + if (!hasThreadExecuting) { return; } @@ -119,13 +119,13 @@ namespace Ryujinx.HLE.HOS.Kernel //Preempts current thread every 10 milliseconds on a round-robin fashion, //when multi core scheduling is disabled, to try ensuring that all threads //gets a chance to run. - while (KeepPreempting) + while (_keepPreempting) { lock (CoreContexts) { - KThread CurrentThread = CoreContexts[CurrentCore].CurrentThread; + KThread currentThread = CoreContexts[_currentCore].CurrentThread; - CurrentThread?.Context.RequestInterrupt(); + currentThread?.Context.RequestInterrupt(); } PreemptThreads(); @@ -134,16 +134,16 @@ namespace Ryujinx.HLE.HOS.Kernel } } - public void ExitThread(KThread Thread) + public void ExitThread(KThread thread) { - Thread.Context.StopExecution(); + thread.Context.StopExecution(); - CoreManager.Exit(Thread.Context.Work); + CoreManager.Exit(thread.Context.Work); } - public void RemoveThread(KThread Thread) + public void RemoveThread(KThread thread) { - CoreManager.RemoveThread(Thread.Context.Work); + CoreManager.RemoveThread(thread.Context.Work); } } }
\ No newline at end of file |