diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-06-13 13:30:13 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-06-13 15:39:47 +0200 |
commit | 14c6648c71b4b8a12ac0905ff23fcd4de7f0556f (patch) | |
tree | 265b9b616486e77ad69820d1fe5fc7feb088bb97 /src/buildtool/build_engine/expression/expression.hpp | |
parent | 1ad1906f2ac3f73ccf2283e4c1cc992557d91161 (diff) | |
download | justbuild-14c6648c71b4b8a12ac0905ff23fcd4de7f0556f.tar.gz |
multithreading: Add AtomicValue to atomically set/get value
... and use it to replace the commonly used pattern in
Expression, LinkedMap, and GitTreeEntry. Furthermore, remove
assignment operators for Expression and LinkedMap as those
are considered to be used in an immutable manner anyway.
Diffstat (limited to 'src/buildtool/build_engine/expression/expression.hpp')
-rw-r--r-- | src/buildtool/build_engine/expression/expression.hpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/buildtool/build_engine/expression/expression.hpp b/src/buildtool/build_engine/expression/expression.hpp index 412de057..6acb1e0e 100644 --- a/src/buildtool/build_engine/expression/expression.hpp +++ b/src/buildtool/build_engine/expression/expression.hpp @@ -20,7 +20,7 @@ #include "src/buildtool/build_engine/expression/target_result.hpp" #include "src/buildtool/common/artifact_description.hpp" #include "src/buildtool/crypto/hash_generator.hpp" -#include "src/utils/cpp/atomic.hpp" +#include "src/buildtool/multithreading/atomic_value.hpp" #include "src/utils/cpp/hex_string.hpp" #include "src/utils/cpp/json.hpp" @@ -63,22 +63,10 @@ class Expression { Expression() noexcept = default; ~Expression() noexcept = default; - Expression(Expression const& other) noexcept - : data_{other.data_}, hash_{other.hash_.load()} {} - Expression(Expression&& other) noexcept - : data_{std::move(other.data_)}, hash_{other.hash_.load()} {} - auto operator=(Expression const& other) noexcept -> Expression& { - if (this != &other) { - data_ = other.data_; - } - hash_ = other.hash_.load(); - return *this; - } - auto operator=(Expression&& other) noexcept -> Expression& { - data_ = std::move(other.data_); - hash_ = other.hash_.load(); - return *this; - } + Expression(Expression const& other) noexcept = default; + Expression(Expression&& other) noexcept = default; + auto operator=(Expression const& other) noexcept = delete; + auto operator=(Expression&& other) noexcept = delete; template <class T> requires(IsValidType<std::remove_cvref_t<T>>()) @@ -256,8 +244,7 @@ class Expression { map_t> data_{none_t{}}; - mutable atomic_shared_ptr<std::string> hash_{}; - mutable std::atomic<bool> hash_loading_{}; + AtomicValue<std::string> hash_{}; template <class T, std::size_t kIndex = 0> requires(IsValidType<T>()) [[nodiscard]] static consteval auto GetIndexOf() |