0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Common/AtomicStorage.cs

27 lines
623 B
C#
Raw Normal View History

using System.Threading;
namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
{
struct AtomicStorage<T> where T: unmanaged
{
public ulong SamplingNumber;
public T Object;
public ulong ReadSamplingNumberAtomic()
{
return Interlocked.Read(ref SamplingNumber);
}
public void SetObject(ref T obj)
{
ISampledData samplingProvider = obj as ISampledData;
Interlocked.Exchange(ref SamplingNumber, samplingProvider.SamplingNumber);
Thread.MemoryBarrier();
Object = obj;
}
}
}