mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-22 18:15:11 +00:00
33 lines
715 B
C#
33 lines
715 B
C#
|
using Ryujinx.Memory;
|
|||
|
using System.Diagnostics;
|
|||
|
using System.Threading;
|
|||
|
|
|||
|
namespace Ryujinx.Cpu
|
|||
|
{
|
|||
|
public abstract class MemoryManagerBase : IRefCounted
|
|||
|
{
|
|||
|
private int _referenceCount;
|
|||
|
|
|||
|
public void IncrementReferenceCount()
|
|||
|
{
|
|||
|
int newRefCount = Interlocked.Increment(ref _referenceCount);
|
|||
|
|
|||
|
Debug.Assert(newRefCount >= 1);
|
|||
|
}
|
|||
|
|
|||
|
public void DecrementReferenceCount()
|
|||
|
{
|
|||
|
int newRefCount = Interlocked.Decrement(ref _referenceCount);
|
|||
|
|
|||
|
Debug.Assert(newRefCount >= 0);
|
|||
|
|
|||
|
if (newRefCount == 0)
|
|||
|
{
|
|||
|
Destroy();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected abstract void Destroy();
|
|||
|
}
|
|||
|
}
|