aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/Memory/KScopedPageList.cs
blob: a0c19f9c14e74d782b7925cc31f1dd460c6a963b (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
using System;

namespace Ryujinx.HLE.HOS.Kernel.Memory
{
    struct KScopedPageList : IDisposable
    {
        private readonly KMemoryManager _manager;
        private KPageList _pageList;

        public KScopedPageList(KMemoryManager manager, KPageList pageList)
        {
            _manager = manager;
            _pageList = pageList;
            pageList.IncrementPagesReferenceCount(manager);
        }

        public void SignalSuccess()
        {
            _pageList = null;
        }

        public void Dispose()
        {
            _pageList?.DecrementPagesReferenceCount(_manager);
        }
    }
}