blob: f488a4f0e0f23a71c7340021704ff862fdb4aebc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "allocator.h"
namespace vespalib::datastore {
/**
* Allocator used to allocate entries of a specific type in an underlying data store
* and uses free lists if available.
*/
template <typename EntryT, typename RefT, typename ReclaimerT>
class FreeListAllocator : public Allocator<EntryT, RefT>
{
public:
using ParentType = Allocator<EntryT, RefT>;
using HandleType = typename ParentType::HandleType;
using ConstArrayRef = typename ParentType::ConstArrayRef;
private:
using ParentType::_store;
using ParentType::_typeId;
public:
FreeListAllocator(DataStoreBase &store, uint32_t typeId);
template <typename ... Args>
HandleType alloc(Args && ... args);
HandleType allocArray(ConstArrayRef array);
HandleType allocArray();
template <typename BufferType>
HandleType alloc_dynamic_array(ConstArrayRef array);
};
}
|