IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
memsys
public
ice
mem_allocator_snake.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/mem_allocator.hxx
>
6
#include <span>
7
8
namespace
ice
9
{
10
11
struct
SnakeAllocatorParams
12
{
13
static
constexpr
ice::usize
Constant_DefaultBlockSizes
[]{ 32_KiB };
14
static
constexpr
ice::usize
Constant_DefaultBucketSizes
[]{ 256_KiB };
15
16
ice::u32
chain_capacity
= 4;
17
18
std::span<ice::usize const>
block_sizes
=
Constant_DefaultBlockSizes
;
19
20
std::span<ice::usize const>
bucket_sizes
=
Constant_DefaultBucketSizes
;
21
};
22
23
struct
SnakeAllocator
:
public
ice::Allocator
24
{
25
SnakeAllocator
(
26
ice::Allocator
& backing_allocator,
27
ice::SnakeAllocatorParams
const
& params = { },
28
std::source_location = std::source_location::current()
29
)
noexcept
;
30
31
SnakeAllocator
(
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
mem_allocator.hxx
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::u32
std::uint32_t u32
Definition
types.hxx:26
ice::Allocator
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition
mem_types.hxx:25
ice::AllocRequest
Definition
mem.hxx:16
ice::AllocResult
Definition
mem.hxx:44
ice::SnakeAllocator::SnakeAllocator
SnakeAllocator(ice::Allocator &backing_allocator, ice::SnakeAllocatorParams const ¶ms={ }, std::source_location=std::source_location::current()) noexcept
ice::SnakeAllocator::do_allocate
auto do_allocate(ice::AllocRequest request) noexcept -> ice::AllocResult override
ice::SnakeAllocator::do_deallocate
void do_deallocate(void *pointer) noexcept override
ice::SnakeAllocator::SnakeAllocator
SnakeAllocator(ice::Allocator &backing_allocator, std::string_view name, ice::SnakeAllocatorParams const ¶ms={ }, std::source_location=std::source_location::current()) noexcept
ice::SnakeAllocator::initialize
void initialize(ice::SnakeAllocatorParams const ¶ms) noexcept
ice::SnakeAllocator::~SnakeAllocator
~SnakeAllocator() noexcept
ice::SnakeAllocatorParams
Definition
mem_allocator_snake.hxx:12
ice::SnakeAllocatorParams::Constant_DefaultBlockSizes
static constexpr ice::usize Constant_DefaultBlockSizes[]
Definition
mem_allocator_snake.hxx:13
ice::SnakeAllocatorParams::chain_capacity
ice::u32 chain_capacity
Definition
mem_allocator_snake.hxx:16
ice::SnakeAllocatorParams::block_sizes
std::span< ice::usize const > block_sizes
Definition
mem_allocator_snake.hxx:18
ice::SnakeAllocatorParams::Constant_DefaultBucketSizes
static constexpr ice::usize Constant_DefaultBucketSizes[]
Definition
mem_allocator_snake.hxx:14
ice::SnakeAllocatorParams::bucket_sizes
std::span< ice::usize const > bucket_sizes
Definition
mem_allocator_snake.hxx:20
ice::usize
Represents a unsigned size value on the given platform.
Definition
mem_size_types.hxx:26
Generated by
1.18.0