aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/flushengine/flushtask.h
blob: a07cd9fae648fcec428b70821273779064bb7a08 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <memory>
#include <vespa/vespalib/util/executor.h>

namespace proton {

class FlushEngine;
class FlushContext;
/**
 * This class decorates a task returned by initFlush() in IFlushTarget so that
 * the appropriate callback is invoked on the running FlushEngine.
 */
class FlushTask : public vespalib::Executor::Task
{
private:
    uint32_t                          _taskId;
    FlushEngine                      &_engine;
    std::shared_ptr<FlushContext>     _context;

public:
    FlushTask(const FlushTask &) = delete;
    FlushTask & operator = (const FlushTask &) = delete;
    /**
     * Constructs a new instance of this class.
     *
     * @param taskId The identifier used by IFlushStrategy.
     * @param engine The running flush engine.
     * @param ctx    The context of the flush to perform.
     */
    FlushTask(uint32_t taskId, FlushEngine &engine, std::shared_ptr<FlushContext> ctx);

    /**
     * Destructor. Notifies the engine that the flush is done to prevent the
     * engine from locking targets because of a glitch.
     */
    ~FlushTask() override;

    void run() override;
};

} // namespace proton