aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/io/coded_stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/io/coded_stream.h')
-rw-r--r--src/google/protobuf/io/coded_stream.h23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index ec85147b..0f70ecde 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -110,6 +110,7 @@
#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__
#include <assert.h>
+#include <atomic>
#include <climits>
#include <string>
#include <utility>
@@ -131,7 +132,6 @@
#define PROTOBUF_LITTLE_ENDIAN 1
#endif
#endif
-#include <google/protobuf/stubs/atomicops.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/port.h>
@@ -829,7 +829,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// canonicalization specification and implement the serializer using
// reflection APIs rather than relying on this API.
//
- // If determinisitc serialization is requested, the serializer will
+ // If deterministic serialization is requested, the serializer will
// sort map entries by keys in lexicographical order or numerical order.
// (This is an implementation detail and may subject to change.)
//
@@ -840,21 +840,18 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// Otherwise, SetSerializationDeterministic has been called, and the last
// value passed to it is all that matters.
void SetSerializationDeterministic(bool value) {
- serialization_deterministic_is_overridden_ = true;
- serialization_deterministic_override_ = value;
+ is_serialization_deterministic_ = value;
}
// See above. Also, note that users of this CodedOutputStream may need to
// call IsSerializationDeterministic() to serialize in the intended way. This
// CodedOutputStream cannot enforce a desire for deterministic serialization
// by itself.
bool IsSerializationDeterministic() const {
- return serialization_deterministic_is_overridden_ ?
- serialization_deterministic_override_ :
- IsDefaultSerializationDeterministic();
+ return is_serialization_deterministic_;
}
static bool IsDefaultSerializationDeterministic() {
- return google::protobuf::internal::NoBarrier_Load(&default_serialization_deterministic_);
+ return default_serialization_deterministic_.load(std::memory_order_relaxed) != 0;
}
private:
@@ -866,12 +863,8 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
int total_bytes_; // Sum of sizes of all buffers seen so far.
bool had_error_; // Whether an error occurred during output.
bool aliasing_enabled_; // See EnableAliasing().
- // See SetSerializationDeterministic() regarding these three fields.
- bool serialization_deterministic_is_overridden_;
- bool serialization_deterministic_override_;
- // Conceptually, default_serialization_deterministic_ is an atomic bool.
- // TODO(haberman): replace with std::atomic<bool> when we move to C++11.
- static google::protobuf::internal::AtomicWord default_serialization_deterministic_;
+ bool is_serialization_deterministic_;
+ static std::atomic<bool> default_serialization_deterministic_;
// Advance the buffer by a given number of bytes.
void Advance(int amount);
@@ -898,7 +891,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// thread has done so.
friend void ::google::protobuf::internal::MapTestForceDeterministic();
static void SetDefaultSerializationDeterministic() {
- google::protobuf::internal::NoBarrier_Store(&default_serialization_deterministic_, 1);
+ default_serialization_deterministic_.store(true, std::memory_order_relaxed);
}
};