0
0
Fork 0
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2024-12-29 19:55:57 +00:00
ryujinx-fork/Ryujinx.Core/OsHle/Handles/HSharedMem.cs

70 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
namespace Ryujinx.Core.OsHle.Handles
2018-02-04 23:08:20 +00:00
{
class HSharedMem
{
private List<long> Positions;
public int PositionsCount => Positions.Count;
public EventHandler<EventArgs> MemoryMapped;
public EventHandler<EventArgs> MemoryUnmapped;
2018-02-04 23:08:20 +00:00
public HSharedMem(long PhysPos)
{
Positions = new List<long>();
}
public void AddVirtualPosition(long Position)
{
lock (Positions)
{
Positions.Add(Position);
MemoryMapped?.Invoke(this, EventArgs.Empty);
}
}
public void RemoveVirtualPosition(long Position)
{
lock (Positions)
{
Positions.Remove(Position);
MemoryUnmapped?.Invoke(this, EventArgs.Empty);
}
}
public long GetVirtualPosition(int Index)
{
lock (Positions)
{
if (Index < 0 || Index >= Positions.Count)
{
throw new ArgumentOutOfRangeException(nameof(Index));
}
return Positions[Index];
}
}
public bool TryGetLastVirtualPosition(out long Position)
{
lock (Positions)
{
if (Positions.Count > 0)
{
Position = Positions[Positions.Count - 1];
return true;
}
Position = 0;
return false;
}
2018-02-04 23:08:20 +00:00
}
}
}