blob: c2d8cfb1a094dfe10ba8d27629e8cfb316710543 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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();
}
}
|