Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmemory_resource_tlsf_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMEMORY_RESOURCE_TLSF_P_H
5#define QMEMORY_RESOURCE_TLSF_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qtclasshelpermacros.h>
19#include <QtMultimedia/private/q_pmr_emulation_p.h>
20
21#include <tlsf.h>
22
23#include <new>
24
25QT_BEGIN_NAMESPACE
26
27namespace QtMultimediaPrivate {
28
30{
31 explicit QTlsfMemoryResource(std::size_t preallocatedBytes,
32 pmr::memory_resource *upstream = pmr::get_default_resource());
33
35
37
38private:
39 void *do_allocate(size_t bytes, size_t alignment) override;
40 void do_deallocate(void *p, size_t bytes, size_t alignment) override;
41 bool do_is_equal(const memory_resource &other) const noexcept override;
42
43 // cache line alignment on most platforms
44 static constexpr auto poolAlignment = std::align_val_t{ 128 };
45
46 QtPrivate::tlsf_t m_tlsf;
47 const size_t m_allocationSize;
48 std::byte *m_buffer = nullptr;
49 pmr::memory_resource *m_upstream{};
50};
51
52} // namespace QtMultimediaPrivate
53
54QT_END_NAMESPACE
55
56#endif // QMEMORY_RESOURCE_TLSF_P_H
void do_deallocate(void *p, size_t bytes, size_t alignment) override
void * do_allocate(size_t bytes, size_t alignment) override
bool do_is_equal(const memory_resource &other) const noexcept override
QTlsfMemoryResource(std::size_t preallocatedBytes, pmr::memory_resource *upstream=pmr::get_default_resource())