mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-13 07:06:41 +00:00
3615a70cae
This reverts commit 85dbb9559a
.
50 lines
No EOL
994 B
C#
50 lines
No EOL
994 B
C#
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
{
|
|
class KSlabHeap
|
|
{
|
|
private LinkedList<ulong> Items;
|
|
|
|
public KSlabHeap(ulong Pa, ulong ItemSize, ulong Size)
|
|
{
|
|
Items = new LinkedList<ulong>();
|
|
|
|
int ItemsCount = (int)(Size / ItemSize);
|
|
|
|
for (int Index = 0; Index < ItemsCount; Index++)
|
|
{
|
|
Items.AddLast(Pa);
|
|
|
|
Pa += ItemSize;
|
|
}
|
|
}
|
|
|
|
public bool TryGetItem(out ulong Pa)
|
|
{
|
|
lock (Items)
|
|
{
|
|
if (Items.First != null)
|
|
{
|
|
Pa = Items.First.Value;
|
|
|
|
Items.RemoveFirst();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
Pa = 0;
|
|
|
|
return false;
|
|
}
|
|
|
|
public void Free(ulong Pa)
|
|
{
|
|
lock (Items)
|
|
{
|
|
Items.AddFirst(Pa);
|
|
}
|
|
}
|
|
}
|
|
} |