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
23QT_BEGIN_NAMESPACE
24
25namespace QtMultimediaPrivate {
26
28{
29 explicit QTlsfMemoryResource(std::size_t preallocatedBytes,
30 pmr::memory_resource *upstream = pmr::get_default_resource());
31
33
35
36private:
37 void *do_allocate(size_t bytes, size_t alignment) override;
38 void do_deallocate(void *p, size_t bytes, size_t alignment) override;
39 bool do_is_equal(const memory_resource &other) const noexcept override;
40
41 // cache line alignment on most platforms
42 static constexpr auto poolAlignment = std::align_val_t{ 128 };
43
44 QtPrivate::tlsf_t m_tlsf;
45 const size_t m_allocationSize;
46 std::byte *m_buffer = nullptr;
47 pmr::memory_resource *m_upstream{};
48};
49
50} // namespace QtMultimediaPrivate
51
52QT_END_NAMESPACE
53
54#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())