blob: 0c821779e033b545f5604dfd0984f4a944ff98b7 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/config-proton.h>
#include <condition_variable>
#include <memory>
#include <mutex>
namespace proton {
class FlushEngine;
/**
* Class ensuring that only a single prepare restart happens at the same time.
*
* If another thread tries to start a new prepare restart while one is running, this thread waits
* until the ongoing operation is done and returns successfully. No extra work is done.
*/
class PrepareRestartHandler {
public:
using ProtonConfig = vespa::config::search::core::internal::InternalProtonType;
private:
FlushEngine &_flushEngine;
std::mutex _mutex;
std::condition_variable _cond;
bool _running;
void performPrepareRestart(const ProtonConfig &protonCfg, std::unique_lock<std::mutex> &lock);
public:
PrepareRestartHandler(FlushEngine &flushEngine);
bool prepareRestart(const ProtonConfig &protonCfg);
};
}
|