Beispiel #1
0
        public Page GetPage(PageNumberInfo number)
        {
            if (ModifiedPages.TryGetValue(number, out var dirtyPage))
            {
                return(dirtyPage);
            }

            if (AllocatedPages.Contains(number))
            {
                return(CreatePage(number));
            }

            var poolPage = Pool.GetEntry(number);

            if (poolPage != null)
            {
                return(poolPage);
            }

            var page = PageManager.GetPage(number);

            if (page == null)
            {
                throw null;
            }

            Pool.AddEntry(page, PageEntryState.None);

            return(page);
        }
Beispiel #2
0
        public Page ModifyPage(PageNumberInfo number)
        {
            if (ModifiedPages.TryGetValue(number, out var page))
            {
                return(page);
            }

            var oldPage = GetPage(number);
            var newPage = ModifyPage(oldPage);

            if (!ModifiedPages.TryAdd(number, newPage))
            {
                throw new InvalidOperationException($"modify page {number.PageNumber} failed!");
            }

            return(newPage);
        }