mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-10-21 06:21:40 +00:00
3443023a08
* hid: Rewrite shared memory management This entirely rewrite our ancient (and original) HID shared memory interface to be more usable and accurate. HID update logics were updated to reflect those changes but should work still the same way it previously did. This need heavy testing just in case to avoid possible regressions. * Silence warnings * Address gdkchan's comments * Address Ac_K's comments * Address one missing nit
26 lines
623 B
C#
26 lines
623 B
C#
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;
|
|
}
|
|
}
|
|
}
|