From 0400cca3236de1ca303af38bf81eab332d042b7c Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Tue, 13 Mar 2018 16:37:29 -0700 Subject: Integrated internal changes from Google --- src/google/protobuf/map_field_inl.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/google/protobuf/map_field_inl.h') 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 -#ifndef _SHARED_PTR_H -#include -#endif +#include #include #include #include @@ -254,7 +252,11 @@ void MapField::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