mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-22 22:05:45 +00:00
Ryujinx.Tests.Unicorn: Implement IDisposable (#3794)
Dispose unicorn when done
This commit is contained in:
parent
9b06ee7736
commit
eafadf10c7
4 changed files with 48 additions and 4 deletions
|
@ -3,9 +3,10 @@ using System;
|
|||
|
||||
namespace Ryujinx.Tests.Unicorn
|
||||
{
|
||||
public class UnicornAArch32
|
||||
public class UnicornAArch32 : IDisposable
|
||||
{
|
||||
internal readonly IntPtr uc;
|
||||
private bool _isDisposed = false;
|
||||
|
||||
public IndexedProperty<int, uint> R
|
||||
{
|
||||
|
@ -107,7 +108,22 @@ namespace Ryujinx.Tests.Unicorn
|
|||
|
||||
~UnicornAArch32()
|
||||
{
|
||||
Interface.Checked(Native.Interface.uc_close(uc));
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
Interface.Checked(Native.Interface.uc_close(uc));
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void RunForCount(ulong count)
|
||||
|
|
|
@ -3,9 +3,10 @@ using System;
|
|||
|
||||
namespace Ryujinx.Tests.Unicorn
|
||||
{
|
||||
public class UnicornAArch64
|
||||
public class UnicornAArch64 : IDisposable
|
||||
{
|
||||
internal readonly IntPtr uc;
|
||||
private bool _isDisposed = false;
|
||||
|
||||
public IndexedProperty<int, ulong> X
|
||||
{
|
||||
|
@ -96,7 +97,22 @@ namespace Ryujinx.Tests.Unicorn
|
|||
|
||||
~UnicornAArch64()
|
||||
{
|
||||
Interface.Checked(Native.Interface.uc_close(uc));
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
Interface.Checked(Native.Interface.uc_close(uc));
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void RunForCount(ulong count)
|
||||
|
|
|
@ -80,6 +80,12 @@ namespace Ryujinx.Tests.Cpu
|
|||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.Dispose();
|
||||
_unicornEmu = null;
|
||||
}
|
||||
|
||||
_memory.DecrementReferenceCount();
|
||||
_context.Dispose();
|
||||
_ram.Dispose();
|
||||
|
|
|
@ -76,6 +76,12 @@ namespace Ryujinx.Tests.Cpu
|
|||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.Dispose();
|
||||
_unicornEmu = null;
|
||||
}
|
||||
|
||||
_memory.DecrementReferenceCount();
|
||||
_context.Dispose();
|
||||
_ram.Dispose();
|
||||
|
|
Loading…
Reference in a new issue