diff options
author | gdkchan <gab.dark.100@gmail.com> | 2018-09-23 15:11:46 -0300 |
---|---|---|
committer | Thomas Guillemard <thog@protonmail.com> | 2018-09-23 20:11:46 +0200 |
commit | 7de7b559adc1924d3ff31cc58b281f70e468155f (patch) | |
tree | 3701e1687f7fc4c4bafdffd5abda1966e6ce320f /Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs | |
parent | 54ed9096bd4add5cf2ca320123f551f60c06a57f (diff) |
Improve kernel events implementation (#430)
* Improve kernel events implementation
* Some cleanup
* Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs b/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs index 868e0172..db9f6fb4 100644 --- a/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs +++ b/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs @@ -1,5 +1,6 @@ using ChocolArm64.State; using Ryujinx.HLE.Logging; +using System.Collections.Generic; using static Ryujinx.HLE.HOS.ErrorCode; @@ -25,22 +26,27 @@ namespace Ryujinx.HLE.HOS.Kernel return; } - KSynchronizationObject[] SyncObjs = new KSynchronizationObject[HandlesCount]; + List<KSynchronizationObject> SyncObjs = new List<KSynchronizationObject>(); for (int Index = 0; Index < HandlesCount; Index++) { int Handle = Memory.ReadInt32(HandlesPtr + Index * 4); - KSynchronizationObject SyncObj = Process.HandleTable.GetData<KSynchronizationObject>(Handle); + KSynchronizationObject SyncObj = Process.HandleTable.GetObject<KSynchronizationObject>(Handle); - SyncObjs[Index] = SyncObj; + if (SyncObj == null) + { + break; + } + + SyncObjs.Add(SyncObj); } int HndIndex = (int)ThreadState.X1; ulong High = ThreadState.X1 & (0xffffffffUL << 32); - long Result = System.Synchronization.WaitFor(SyncObjs, Timeout, ref HndIndex); + long Result = System.Synchronization.WaitFor(SyncObjs.ToArray(), Timeout, ref HndIndex); if (Result != 0) { @@ -65,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Kernel Device.Log.PrintDebug(LogClass.KernelSvc, "ThreadHandle = 0x" + ThreadHandle.ToString("x8")); - KThread Thread = Process.HandleTable.GetData<KThread>(ThreadHandle); + KThread Thread = Process.HandleTable.GetKThread(ThreadHandle); if (Thread == null) { |