line |
true |
false |
branch |
16
|
18 |
0 |
DynamicMemoryPool* DynamicMemoryPool::_global_instance = new DynamicMemoryPool(); |
19
|
0 |
0 |
string key(ti.name()); |
20
|
0 |
0 |
if (name) key += name; |
|
0 |
0 |
if (name) key += name; |
22
|
0 |
0 |
std::lock_guard guard(global_ptrs_mutex); |
23
|
0 |
0 |
auto it = global_ptrs.find(key); |
24
|
0 |
0 |
if (it != global_ptrs.end()) return it->second; |
26
|
0 |
0 |
global_ptrs.emplace(key, val); |
31
|
4 |
0 |
string key(ti.name()); |
32
|
4 |
0 |
if (name) key += name; |
|
4 |
0 |
if (name) key += name; |
34
|
4 |
0 |
auto it = global_tls_ptrs.find(key); |
35
|
0 |
4 |
if (it != global_tls_ptrs.end()) return it->second; |
37
|
4 |
0 |
global_tls_ptrs.emplace(key, val); |
43
|
0 |
4 |
if (pools_cnt) { |
54
|
64 |
4 |
while (elem < end) { |
65
|
0 |
0 |
while (pool >= first) { // from last to first, because most possibility that elem is in latest pools |
66
|
0 |
0 |
if (elem >= pool->list && elem < pool->list + pool->len) return true; |
|
0 |
0 |
if (elem >= pool->list && elem < pool->list + pool->len) return true; |
72
|
0 |
0 |
MemoryPool::~MemoryPool () { |
73
|
0 |
0 |
if (!pools.size()) return; |
76
|
0 |
0 |
while (pool <= last) { |
77
|
0 |
0 |
delete[] pool->list; |
86
|
22 |
0 |
small_pools[0] = small_pools[1] = new MemoryPool(8); // min bytes = 8, make 4-byte and 8-byte requests shared |
90
|
0 |
0 |
for (int i = 0; i < POOLS_CNT; ++i) { |
91
|
0 |
0 |
if (i) delete small_pools[i]; |
|
0 |
0 |
if (i) delete small_pools[i]; |
92
|
0 |
0 |
delete medium_pools[i]; |
93
|
0 |
0 |
delete big_pools[i]; |
97
|
4 |
8 |
} |
|
18 |
0 |
} |
|
18 |
0 |
} |