aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/attribute/attribute_executor.h
blob: 4a13fe1d886e773f98521ab767d81591dc98edda (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <functional>
#include <memory>

namespace search { class AttributeVector; }

namespace proton {

struct IAttributeManager;

/*
 * Class for executing task in attribute vector write thread.
 */
class AttributeExecutor
{
private:
    std::shared_ptr<IAttributeManager>           _mgr;
    std::shared_ptr<search::AttributeVector>     _attr;

public:
    AttributeExecutor(std::shared_ptr<IAttributeManager> mgr,
                      std::shared_ptr<search::AttributeVector> attr);
    ~AttributeExecutor();
    void run_sync(std::function<void()> task) const;
    const search::AttributeVector& get_attr() const noexcept { return *_attr; }
};

} // namespace proton