mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-16 01:55:27 +00:00
fb1d9493a3
* 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 ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Apply previous refactorings to the merged code
81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using Ryujinx.Common;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
{
|
|
class KCoreContext
|
|
{
|
|
private KScheduler _scheduler;
|
|
|
|
private HleCoreManager _coreManager;
|
|
|
|
public bool ContextSwitchNeeded { get; private set; }
|
|
|
|
public long LastContextSwitchTime { get; private set; }
|
|
|
|
public long TotalIdleTimeTicks { get; private set; } //TODO
|
|
|
|
public KThread CurrentThread { get; private set; }
|
|
public KThread SelectedThread { get; private set; }
|
|
|
|
public KCoreContext(KScheduler scheduler, HleCoreManager coreManager)
|
|
{
|
|
_scheduler = scheduler;
|
|
_coreManager = coreManager;
|
|
}
|
|
|
|
public void SelectThread(KThread thread)
|
|
{
|
|
SelectedThread = thread;
|
|
|
|
if (SelectedThread != CurrentThread)
|
|
{
|
|
ContextSwitchNeeded = true;
|
|
}
|
|
}
|
|
|
|
public void UpdateCurrentThread()
|
|
{
|
|
ContextSwitchNeeded = false;
|
|
|
|
LastContextSwitchTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
long currentTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread.TotalTimeRunning += currentTime - CurrentThread.LastScheduledTime;
|
|
CurrentThread.LastScheduledTime = currentTime;
|
|
}
|
|
}
|
|
|
|
public void ContextSwitch()
|
|
{
|
|
ContextSwitchNeeded = false;
|
|
|
|
LastContextSwitchTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
_coreManager.Reset(CurrentThread.Context.Work);
|
|
}
|
|
|
|
CurrentThread = SelectedThread;
|
|
|
|
if (CurrentThread != null)
|
|
{
|
|
long currentTime = PerformanceCounter.ElapsedMilliseconds;
|
|
|
|
CurrentThread.TotalTimeRunning += currentTime - CurrentThread.LastScheduledTime;
|
|
CurrentThread.LastScheduledTime = currentTime;
|
|
|
|
CurrentThread.ClearExclusive();
|
|
|
|
_coreManager.Set(CurrentThread.Context.Work);
|
|
|
|
CurrentThread.Context.Execute();
|
|
}
|
|
}
|
|
}
|
|
} |