IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
mem_allocator_snake.hxx
Go to the documentation of this file.
1
3
4#pragma once
6#include <span>
7
8namespace ice
9{
10
12 {
13 static constexpr ice::usize Constant_DefaultBlockSizes[]{ 32_KiB };
14 static constexpr ice::usize Constant_DefaultBucketSizes[]{ 256_KiB };
15
17
18 std::span<ice::usize const> block_sizes = Constant_DefaultBlockSizes;
19
20 std::span<ice::usize const> bucket_sizes = Constant_DefaultBucketSizes;
21 };
22
24 {
26 ice::Allocator& backing_allocator,
27 ice::SnakeAllocatorParams const& params = { },
28 std::source_location = std::source_location::current()
29 ) noexcept;
30
32 ice::Allocator& backing_allocator,
33 std::string_view name,
34 ice::SnakeAllocatorParams const& params = { },
35 std::source_location = std::source_location::current()
36 ) noexcept;
37
38 ~SnakeAllocator() noexcept;
39
40 protected:
41 auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override;
42 void do_deallocate(void* pointer) noexcept override;
43
44 void initialize(ice::SnakeAllocatorParams const& params) noexcept;
45
46 private:
47 struct Chain;
48 struct ChainBlock;
49
50 ice::Allocator& _backing_allocator;
51
52 Chain* _chains;
53 ChainBlock* _blocks;
54 };
55
56} // namespace ice
SPDX-License-Identifier: MIT.
Definition array.hxx:12
std::uint32_t u32
Definition types.hxx:26
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition mem_types.hxx:25
Definition mem.hxx:16
Definition mem.hxx:44
SnakeAllocator(ice::Allocator &backing_allocator, ice::SnakeAllocatorParams const &params={ }, std::source_location=std::source_location::current()) noexcept
auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override
void do_deallocate(void *pointer) noexcept override
SnakeAllocator(ice::Allocator &backing_allocator, std::string_view name, ice::SnakeAllocatorParams const &params={ }, std::source_location=std::source_location::current()) noexcept
void initialize(ice::SnakeAllocatorParams const &params) noexcept
~SnakeAllocator() noexcept
Definition mem_allocator_snake.hxx:12
static constexpr ice::usize Constant_DefaultBlockSizes[]
Definition mem_allocator_snake.hxx:13
ice::u32 chain_capacity
Definition mem_allocator_snake.hxx:16
std::span< ice::usize const > block_sizes
Definition mem_allocator_snake.hxx:18
static constexpr ice::usize Constant_DefaultBucketSizes[]
Definition mem_allocator_snake.hxx:14
std::span< ice::usize const > bucket_sizes
Definition mem_allocator_snake.hxx:20
Represents a unsigned size value on the given platform.
Definition mem_size_types.hxx:26