mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2025-04-17 14:34:05 -05:00

* - add new abstract class `VirtualMemoryManagerBase` - rename `MemoryManagerBase` to `VirtualMemoryManagerRefCountedBase` and derive from `VirtualMemoryManagerBase` - change `AddressSpaceManager`, `HvMemoryManager`, `MemoryManager`, and `MemoryManagerHostMapped` to implement abstract members and use the inherited `void VirtualMemoryManagerBase.Read(TVirtual va, Span<byte> data)` implementation. * move property `AddressSpaceSize` up by the other properties
36 lines
922 B
C#
36 lines
922 B
C#
using Ryujinx.Memory;
|
|
using System.Diagnostics;
|
|
using System.Numerics;
|
|
using System.Threading;
|
|
|
|
namespace Ryujinx.Cpu
|
|
{
|
|
public abstract class VirtualMemoryManagerRefCountedBase<TVirtual, TPhysical> : VirtualMemoryManagerBase<TVirtual, TPhysical>, IRefCounted
|
|
where TVirtual : IBinaryInteger<TVirtual>
|
|
where TPhysical : IBinaryInteger<TPhysical>
|
|
{
|
|
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();
|
|
}
|
|
}
|