Mosa.HardwareSystem.MemoryResources.ClaimResources C# (CSharp) Method

ClaimResources() public method

Claims the resources.
public ClaimResources ( HardwareResources hardwareResources ) : bool
hardwareResources HardwareResources The hardware resources.
return bool
        public bool ClaimResources(HardwareResources hardwareResources)
        {
            spinLock.Enter();

            for (byte r = 0; r < hardwareResources.MemoryRegionCount; r++)
            {
                var region = hardwareResources.GetMemoryRegion(r);

                foreach (var memoryRegion in memoryRegions)
                {
                    if ((memoryRegion.Contains(region.BaseAddress) || memoryRegion.Contains(region.BaseAddress + region.Size)))
                        return false;
                }
            }

            for (byte r = 0; r < hardwareResources.MemoryRegionCount; r++)
            {
                memoryRegions.AddLast(hardwareResources.GetMemoryRegion(r));
            }

            spinLock.Exit();

            return true;
        }