aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Arp/Detail/ApplicationInstanceManager.cs
blob: 18c993ce4d2297551bd88653f1b6665e10b29992 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Ryujinx.Horizon.Sdk.OsTypes;
using System;
using System.Threading;

namespace Ryujinx.Horizon.Sdk.Arp.Detail
{
    class ApplicationInstanceManager : IDisposable
    {
        private int _disposalState;

        public SystemEventType SystemEvent;
        public int EventHandle;

        public readonly ApplicationInstance[] Entries = new ApplicationInstance[2];

        public ApplicationInstanceManager()
        {
            Os.CreateSystemEvent(out SystemEvent, EventClearMode.ManualClear, true).AbortOnFailure();

            EventHandle = Os.GetReadableHandleOfSystemEvent(ref SystemEvent);
        }

        public void Dispose()
        {
            if (EventHandle != 0 && Interlocked.Exchange(ref _disposalState, 1) == 0)
            {
                Os.DestroySystemEvent(ref SystemEvent);
            }
        }
    }
}