/src/immer/immer/heap/split_heap.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // immer: immutable data structures for C++ |
3 | | // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente |
4 | | // |
5 | | // This software is distributed under the Boost Software License, Version 1.0. |
6 | | // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt |
7 | | // |
8 | | |
9 | | #pragma once |
10 | | |
11 | | #include <atomic> |
12 | | #include <cassert> |
13 | | #include <cstddef> |
14 | | |
15 | | namespace immer { |
16 | | |
17 | | /*! |
18 | | * Adaptor that uses `SmallHeap` for allocations that are smaller or |
19 | | * equal to `Size` and `BigHeap` otherwise. |
20 | | */ |
21 | | template <std::size_t Size, typename SmallHeap, typename BigHeap> |
22 | | struct split_heap |
23 | | { |
24 | | template <typename... Tags> |
25 | | static void* allocate(std::size_t size, Tags... tags) |
26 | 42.2M | { |
27 | 42.2M | return size <= Size ? SmallHeap::allocate(size, tags...) |
28 | 42.2M | : BigHeap::allocate(size, tags...); |
29 | 42.2M | } void* immer::split_heap<56ul, immer::with_free_list_node<immer::thread_local_free_list_heap<56ul, 1024ul, immer::free_list_heap<56ul, 1024ul, immer::debug_size_heap<immer::cpp_heap> > > >, immer::debug_size_heap<immer::cpp_heap> >::allocate<>(unsigned long) Line | Count | Source | 26 | 25.7M | { | 27 | 25.7M | return size <= Size ? SmallHeap::allocate(size, tags...) | 28 | 25.7M | : BigHeap::allocate(size, tags...); | 29 | 25.7M | } |
void* immer::split_heap<56ul, immer::with_free_list_node<immer::thread_local_free_list_heap<56ul, 1024ul, immer::free_list_heap<56ul, 1024ul, immer::debug_size_heap<immer::cpp_heap> > > >, immer::debug_size_heap<immer::cpp_heap> >::allocate<immer::norefs_tag>(unsigned long, immer::norefs_tag) Line | Count | Source | 26 | 16.5M | { | 27 | 16.5M | return size <= Size ? SmallHeap::allocate(size, tags...) | 28 | 16.5M | : BigHeap::allocate(size, tags...); | 29 | 16.5M | } |
|
30 | | |
31 | | template <typename... Tags> |
32 | | static void deallocate(std::size_t size, void* data, Tags... tags) |
33 | 42.2M | { |
34 | 42.2M | if (size <= Size) |
35 | 42.2M | SmallHeap::deallocate(size, data, tags...); |
36 | 0 | else |
37 | 0 | BigHeap::deallocate(size, data, tags...); |
38 | 42.2M | } |
39 | | }; |
40 | | |
41 | | } // namespace immer |