diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-04-02 16:32:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 16:32:09 +0200 |
commit | 47019081334e7a779eda4d241546e663ed8f87bc (patch) | |
tree | c4a497909d40b86177c86182710ccf11a0a42cb5 /vespalib | |
parent | 6c8775e83f0b5e8480eed1276bb757e3b5940ec4 (diff) | |
parent | 533ed4c1ed5b2a0e45bc9fe5a518d23da5f5cd17 (diff) |
Merge pull request #12797 from vespa-engine/balder/construct-addresses-construction-time
- Redo the servicepool to resolve addresses first time and not loadba…
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/gencnt.cpp | 2 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/gencnt.h | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/vespalib/src/vespa/vespalib/util/gencnt.cpp b/vespalib/src/vespa/vespalib/util/gencnt.cpp index 5adbf14a757..ad82cf2e67c 100644 --- a/vespalib/src/vespa/vespalib/util/gencnt.cpp +++ b/vespalib/src/vespa/vespalib/util/gencnt.cpp @@ -58,7 +58,7 @@ GenCnt::distance(const GenCnt &other) const GenCnt & GenCnt::operator=(const GenCnt &src) { - _val = src._val; + _val = src.getAsInt(); return *this; } diff --git a/vespalib/src/vespa/vespalib/util/gencnt.h b/vespalib/src/vespa/vespalib/util/gencnt.h index 7bfc5a7e49b..cac868a8adb 100644 --- a/vespalib/src/vespa/vespalib/util/gencnt.h +++ b/vespalib/src/vespa/vespalib/util/gencnt.h @@ -2,6 +2,7 @@ #pragma once #include <cstdint> +#include <atomic> namespace vespalib { @@ -16,7 +17,7 @@ namespace vespalib { class GenCnt { private: - uint32_t _val; + std::atomic<uint32_t> _val; public: /** @@ -31,12 +32,12 @@ public: **/ GenCnt(uint32_t val) : _val(val) {} - GenCnt(const GenCnt &rhs) = default; + GenCnt(const GenCnt &rhs) : _val(rhs.getAsInt()) {} /** * @brief empty destructor **/ - ~GenCnt() {} + ~GenCnt() = default; /** * @brief Increase the generation count held by this object @@ -95,7 +96,7 @@ public: * * @return generation counter **/ - uint32_t getAsInt() const { return _val; } + uint32_t getAsInt() const { return _val.load(std::memory_order_relaxed); } /** * @brief Set the generation counter from an integer |