diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2023-01-04 20:01:44 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-05 00:01:44 +0100 |
| commit | fc4b7cba2c083b3920f2d74e0cb4b08cf7a5a278 (patch) | |
| tree | baa5d9a71ee011ecbaeee9a67e037cb399eb7d0e /Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs | |
| parent | 08831eecf77cedd3c4192ebab5a9c485fb15d51e (diff) | |
Make PPTC state non-static (#4157)
* Make PPTC state non-static
* DiskCacheLoadState can be null
Diffstat (limited to 'Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs')
| -rw-r--r-- | Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs b/Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs new file mode 100644 index 00000000..7a4b670b --- /dev/null +++ b/Ryujinx.Cpu/Jit/JitDiskCacheLoadState.cs @@ -0,0 +1,38 @@ +using ARMeilleure.Translation.PTC; +using System; + +namespace Ryujinx.Cpu.Jit +{ + public class JitDiskCacheLoadState : IDiskCacheLoadState + { + /// <inheritdoc/> + public event Action<LoadState, int, int> StateChanged; + + private readonly IPtcLoadState _loadState; + + public JitDiskCacheLoadState(IPtcLoadState loadState) + { + loadState.PtcStateChanged += LoadStateChanged; + _loadState = loadState; + } + + private void LoadStateChanged(PtcLoadingState newState, int current, int total) + { + LoadState state = newState switch + { + PtcLoadingState.Start => LoadState.Unloaded, + PtcLoadingState.Loading => LoadState.Loading, + PtcLoadingState.Loaded => LoadState.Loaded, + _ => throw new ArgumentException($"Invalid load state \"{newState}\".") + }; + + StateChanged?.Invoke(state, current, total); + } + + /// <inheritdoc/> + public void Cancel() + { + _loadState.Continue(); + } + } +}
\ No newline at end of file |
