diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-05-05 11:40:53 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-05-05 11:40:53 +0200 |
commit | 82b52b9263f27593220dc9e6ac8982bbe3a1d0f3 (patch) | |
tree | 4a02dec41a36b6ca8f4ebca14d59dbd32443e804 /searchcore | |
parent | a6f4bcefc08cb924b179cc1eadd9b2f95f2ffab1 (diff) |
Make proton::TlsReplayProgress::_current atomic.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/server/tls_replay_progress.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/tls_replay_progress.h b/searchcore/src/vespa/searchcore/proton/server/tls_replay_progress.h index ce0195ad120..5bd1b6382f4 100644 --- a/searchcore/src/vespa/searchcore/proton/server/tls_replay_progress.h +++ b/searchcore/src/vespa/searchcore/proton/server/tls_replay_progress.h @@ -4,6 +4,7 @@ #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/stllike/string.h> +#include <atomic> namespace proton { @@ -13,7 +14,7 @@ private: const vespalib::string _domainName; const search::SerialNum _first; const search::SerialNum _last; - search::SerialNum _current; + std::atomic<search::SerialNum> _current; public: typedef std::unique_ptr<TlsReplayProgress> UP; @@ -27,18 +28,18 @@ public: _current(first) { } - const vespalib::string &getDomainName() const { return _domainName; } - search::SerialNum getFirst() const { return _first; } - search::SerialNum getLast() const { return _last; } - search::SerialNum getCurrent() const { return _current; } - float getProgress() const { + 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)(_current - _first)/float(_last - _first)); + return ((float)(getCurrent() - _first)/float(_last - _first)); } } - void updateCurrent(search::SerialNum current) { _current = current; } + void updateCurrent(search::SerialNum current) noexcept { _current.store(current, std::memory_order_relaxed); } }; } // namespace proton |