MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
thread/mtcore_thread/alloc.hpp
Go to the documentation of this file.
1/*
2
3Copyright 2025 Matthew Tolman
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16
17*/
18
19#pragma once
20
21#ifndef MTCORE_THREAD_ALLOC_HPP
22#define MTCORE_THREAD_ALLOC_HPP
23
25#include "mtcore/alloc.hpp"
26#include <mutex>
27
35namespace mtcore::thread {
50
67 DynamicArenaAllocator dynamic_arena(Allocator *root, size_t elementSizeHint, size_t elementCountHint) noexcept;
68
83
98
113
124
139
159} // namespace mtcore::thread
160
161#endif // MTCORE_THREAD_ALLOC_HPP
FixedArenaAllocator fixed_arena(Slice< u8 > bytes) noexcept
Creates basic arena allocator which just pushes more state onto the end Calling deinit will simply re...
DynamicArenaAllocator dynamic_arena(Allocator *root, size_t elementSizeHint, size_t elementCountHint) noexcept
Creates a dynamically growing arena allocator This arena allocator will grow if it runs out of space ...
DebugAllocator debug_alloc() noexcept
Creates a memory allocator using the standard's malloc under the hood This allocator will do basic tr...
FixedBufferAllocator fixed_buff(Slice< u8 > bytes) noexcept
Creates an allocator that works on a fixed buffer of bytes.
uint8_t u8
Alias for 8-bit unsigned ints.
Thread-related namespace The methods and classes provided by this class are thread-safe Classes and m...
Represents a memory allocator Exact behavior depends on the underlying VTable used Should use the a_*...
A Slice which is just a pointer + length Accessing elements through the array operator will do bounds...
State variable for thread local debug allocator Must live longer (and at the same memory address) tha...
State variable for thread local dynamic arena allocator Must live longer (and at the same memory addr...
State variable for thread local fixed arena allocator Must live longer (and at the same memory addres...
State variable for thread local fixed buffer allocator Must live longer (and at the same memory addre...
Allocator state object for shared debug allocation Must live longer (and at the same memory address) ...
Allocator allocator() noexcept
Allocator state object for shared dynamic arena allocation Must live longer (and at the same memory a...
Allocator state object for shared fixed arena allocation Must live longer (and at the same memory add...
Allocator state object for shared fixed buffer allocation Must live longer (and at the same memory ad...