aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs b/Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs
index 812cbd30..a94b280f 100644
--- a/Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs
+++ b/Ryujinx.HLE/HOS/Kernel/Common/KAutoObject.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics;
using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Common
@@ -47,17 +48,25 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
public void IncrementReferenceCount()
{
- Interlocked.Increment(ref _referenceCount);
+ int newRefCount = Interlocked.Increment(ref _referenceCount);
+
+ Debug.Assert(newRefCount >= 2);
}
public void DecrementReferenceCount()
{
- if (Interlocked.Decrement(ref _referenceCount) == 0)
+ int newRefCount = Interlocked.Decrement(ref _referenceCount);
+
+ Debug.Assert(newRefCount >= 0);
+
+ if (newRefCount == 0)
{
Destroy();
}
}
- protected virtual void Destroy() { }
+ protected virtual void Destroy()
+ {
+ }
}
} \ No newline at end of file