blob: cbe47d37e76627bf63a0c05f087be1d5e4e80b59 (
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
38
39
40
41
42
43
44
45
46
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "unique_store_entry_base.h"
#include <cassert>
#include <utility>
namespace vespalib::datastore {
template<typename EntryType>
struct UniqueStoreEntryReclaimer {
static void reclaim(EntryType *entry) {
assert(entry->get_ref_count() == 0u);
}
};
/*
* Class for entries in unique store.
*/
template <typename EntryT>
class UniqueStoreEntry : public UniqueStoreEntryBase {
using EntryType = EntryT;
EntryType _value;
public:
UniqueStoreEntry()
: UniqueStoreEntryBase(),
_value()
{
}
explicit UniqueStoreEntry(const EntryType& value)
: UniqueStoreEntryBase(),
_value(value)
{
}
explicit UniqueStoreEntry(EntryType&& value)
: UniqueStoreEntryBase(),
_value(std::move(value))
{
}
const EntryType& value() const { return _value; }
EntryType& value() { return _value; }
};
}
|