aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/map_field_inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/map_field_inl.h')
-rw-r--r--src/google/protobuf/map_field_inl.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h
index e317b5ed..d0517792 100644
--- a/src/google/protobuf/map_field_inl.h
+++ b/src/google/protobuf/map_field_inl.h
@@ -32,10 +32,8 @@
#define GOOGLE_PROTOBUF_MAP_FIELD_INL_H__
#include <memory>
-#ifndef _SHARED_PTR_H
-#include <google/protobuf/stubs/shared_ptr.h>
-#endif
+#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/map.h>
#include <google/protobuf/map_field.h>
#include <google/protobuf/map_type_handler.h>
@@ -254,7 +252,11 @@ void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType,
default_enum_value>::Swap(MapField* other) {
std::swap(this->MapFieldBase::repeated_field_, other->repeated_field_);
impl_.Swap(&other->impl_);
- std::swap(this->MapFieldBase::state_, other->state_);
+ // a relaxed swap of the atomic
+ auto other_state = other->state_.load(std::memory_order_relaxed);
+ auto this_state = this->MapFieldBase::state_.load(std::memory_order_relaxed);
+ other->state_.store(this_state, std::memory_order_relaxed);
+ this->MapFieldBase::state_.store(other_state, std::memory_order_relaxed);
}
template <typename Derived, typename Key, typename T,