0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-24 12:05:47 +00:00
Ryujinx/Ryujinx.HLE/HOS/Kernel/KSlabHeap.cs

50 lines
994 B
C#
Raw Normal View History

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);
}
}
}
}