aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/reprocessing/reprocessingrunner.h
blob: e5004d2e7c302a0ee7ca21bc528edb5b5da7e421 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <mutex>
#include <memory>
#include <vector>

namespace proton {

class IReprocessingTask;

/**
 * Class for running reprocessing task.
 */
class ReprocessingRunner
{
public:
    using ReprocessingTasks = std::vector<std::shared_ptr<IReprocessingTask>>;
private:
    mutable std::mutex _lock;
    ReprocessingTasks _tasks; // Protected by _lock
    enum State
    {
        NOT_STARTED,
        RUNNING,
        DONE
    };
    State _state;
public:
    ReprocessingRunner();

    void addTasks(const ReprocessingTasks &tasks);
    void run();
    void reset();
    bool empty() const;
    double getProgress() const;
};

} // namespace proton