aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/generationholder.h
blob: 00ce8182394d1a22d0e4b020f3abf653157c2148 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "generation_hold_list.h"
#include "generationhandler.h"
#include <memory>

namespace vespalib {

class GenerationHeldBase
{
public:
    using generation_t = GenerationHandler::generation_t;
    using UP = std::unique_ptr<GenerationHeldBase>;
    using SP = std::shared_ptr<GenerationHeldBase>;

private:
    size_t	 _byte_size;

public:
    GenerationHeldBase(size_t byte_size_in)
        : _byte_size(byte_size_in)
    { }

    virtual ~GenerationHeldBase();
    size_t byte_size() const { return _byte_size; }
};

using GenerationHolderParent = GenerationHoldList<GenerationHeldBase::UP, true, false>;

/*
 * GenerationHolder is meant to hold large elements until readers can
 * no longer access them.
 */
class GenerationHolder : public GenerationHolderParent {
public:
    GenerationHolder();
};

}