blob: 5bd1b6382f49f06403def8b77f1e2219b87a2482 (
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
45
46
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/common/serialnum.h>
#include <vespa/vespalib/stllike/string.h>
#include <atomic>
namespace proton {
class TlsReplayProgress
{
private:
const vespalib::string _domainName;
const search::SerialNum _first;
const search::SerialNum _last;
std::atomic<search::SerialNum> _current;
public:
typedef std::unique_ptr<TlsReplayProgress> UP;
TlsReplayProgress(const vespalib::string &domainName,
search::SerialNum first,
search::SerialNum last)
: _domainName(domainName),
_first(first),
_last(last),
_current(first)
{
}
const vespalib::string &getDomainName() const noexcept { return _domainName; }
search::SerialNum getFirst() const noexcept { return _first; }
search::SerialNum getLast() const noexcept { return _last; }
search::SerialNum getCurrent() const noexcept { return _current.load(std::memory_order_relaxed); }
float getProgress() const noexcept {
if (_first == _last) {
return 1.0;
} else {
return ((float)(getCurrent() - _first)/float(_last - _first));
}
}
void updateCurrent(search::SerialNum current) noexcept { _current.store(current, std::memory_order_relaxed); }
};
} // namespace proton
|