update credits
[LibreOffice.git] / sal / rtl / alloc_cache.hxx
blob877ec82ce37f24108e4470160a3f6e4910d8f931
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_ALLOC_CACHE_HXX
21 #define INCLUDED_RTL_ALLOC_CACHE_HXX
23 #include "sal/types.h"
24 #include "rtl/alloc.h"
25 #include "alloc_impl.hxx"
27 /** rtl_cache_stat_type
28 * @internal
30 struct rtl_cache_stat_type
32 sal_uInt64 m_alloc;
33 sal_uInt64 m_free;
35 sal_Size m_mem_total;
36 sal_Size m_mem_alloc;
40 /** rtl_cache_bufctl_type
41 * @internal
43 struct rtl_cache_bufctl_type
45 rtl_cache_bufctl_type * m_next; /* linkage */
47 sal_uIntPtr m_addr; /* buffer address */
48 sal_uIntPtr m_slab; /* parent slab address */
52 /** rtl_cache_slab_type
53 * @internal
55 struct rtl_cache_slab_type
57 rtl_cache_slab_type * m_slab_next; /* slab linkage */
58 rtl_cache_slab_type * m_slab_prev; /* slab linkage */
60 sal_Size m_ntypes; /* number of buffers used */
61 sal_uIntPtr m_data; /* buffer start addr */
63 sal_uIntPtr m_bp; /* free buffer linkage 'base pointer' */
64 rtl_cache_bufctl_type * m_sp; /* free buffer linkage 'stack pointer' */
68 /** rtl_cache_magazine_type
69 * @internal
71 #define RTL_CACHE_MAGAZINE_SIZE 61
73 struct rtl_cache_magazine_type
75 rtl_cache_magazine_type * m_mag_next; /* depot linkage */
77 sal_Size m_mag_size;
78 sal_Size m_mag_used;
80 void * m_objects[RTL_CACHE_MAGAZINE_SIZE];
84 /** rtl_cache_depot_type
85 * @internal
87 struct rtl_cache_depot_type
89 /* magazine list */
90 rtl_cache_magazine_type * m_mag_next; /* linkage */
91 sal_Size m_mag_count; /* count */
93 /* working set parameters */
94 sal_Size m_curr_min;
95 sal_Size m_prev_min;
99 /** rtl_cache_type
100 * @internal
102 #define RTL_CACHE_HASH_SIZE 8
104 #define RTL_CACHE_FEATURE_HASH 1
105 #define RTL_CACHE_FEATURE_BULKDESTROY 2
106 #define RTL_CACHE_FEATURE_RESCALE 4 /* within hash rescale operation */
108 struct rtl_cache_st
110 /* linkage */
111 rtl_cache_type * m_cache_next;
112 rtl_cache_type * m_cache_prev;
114 /* properties */
115 char m_name[RTL_CACHE_NAME_LENGTH + 1];
116 long m_features;
118 sal_Size m_type_size; /* const */
119 sal_Size m_type_align; /* const */
120 sal_Size m_type_shift; /* log2(m_type_size); const */
122 int (SAL_CALL * m_constructor)(void * obj, void * userarg); /* const */
123 void (SAL_CALL * m_destructor) (void * obj, void * userarg); /* const */
124 void (SAL_CALL * m_reclaim) (void * userarg); /* const */
125 void * m_userarg;
127 /* slab layer */
128 rtl_memory_lock_type m_slab_lock;
129 rtl_cache_stat_type m_slab_stats;
131 rtl_arena_type * m_source; /* slab supplier; const */
132 sal_Size m_slab_size; /* const */
133 sal_Size m_ntypes; /* number of buffers per slab; const */
134 sal_Size m_ncolor; /* next slab color */
135 sal_Size m_ncolor_max; /* max. slab color */
137 rtl_cache_slab_type m_free_head;
138 rtl_cache_slab_type m_used_head;
140 rtl_cache_bufctl_type ** m_hash_table;
141 rtl_cache_bufctl_type * m_hash_table_0[RTL_CACHE_HASH_SIZE];
142 sal_Size m_hash_size; /* m_hash_mask + 1 */
143 sal_Size m_hash_shift; /* log2(m_hash_size) */
145 /* depot layer */
146 rtl_memory_lock_type m_depot_lock;
148 rtl_cache_depot_type m_depot_empty;
149 rtl_cache_depot_type m_depot_full;
151 rtl_cache_type * m_magazine_cache; /* magazine supplier; const */
153 /* cpu layer */
154 rtl_cache_magazine_type * m_cpu_curr;
155 rtl_cache_magazine_type * m_cpu_prev;
157 rtl_cache_stat_type m_cpu_stats;
160 #endif /* INCLUDED_RTL_ALLOC_CACHE_HXX */
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */