blob: 1c09062aa1dddf7caa8f0b883355da1109ba575e (
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "i_maintenance_job.h"
#include "imaintenancejobrunner.h"
#include <vespa/vespalib/util/executor.h>
#include <mutex>
namespace proton {
class MaintenanceJobRunner : public IMaintenanceJobRunner
{
private:
using Mutex = std::mutex;
using Guard = std::lock_guard<Mutex>;
vespalib::Executor &_executor;
IMaintenanceJob::UP _job;
bool _stopped;
bool _queued;
bool _running;
mutable Mutex _lock;
void addExecutorTask();
void runJobInExecutor();
public:
using SP = std::shared_ptr<MaintenanceJobRunner>;
MaintenanceJobRunner(vespalib::Executor &executor, IMaintenanceJob::UP job);
void run() override;
void stop();
bool isRunnable() const;
const IMaintenanceJob &getJob() const { return *_job; }
IMaintenanceJob &getJob() { return *_job; }
};
} // namespace proton
|