Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: third_party/protobuf/src/google/protobuf/stubs/once.h

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/stubs/once.h
diff --git a/third_party/protobuf/src/google/protobuf/stubs/once.h b/third_party/protobuf/src/google/protobuf/stubs/once.h
index 9f1c5fc6469f5fa654a2d6b1c2eea9230ce5c1b8..9522b22a1c22657e5154734b86e4a417bb081d39 100644
--- a/third_party/protobuf/src/google/protobuf/stubs/once.h
+++ b/third_party/protobuf/src/google/protobuf/stubs/once.h
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -79,6 +79,7 @@
#define GOOGLE_PROTOBUF_STUBS_ONCE_H__
#include <google/protobuf/stubs/atomicops.h>
+#include <google/protobuf/stubs/callback.h>
#include <google/protobuf/stubs/common.h>
namespace google {
@@ -135,6 +136,24 @@ inline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg*),
#endif // GOOGLE_PROTOBUF_NO_THREAD_SAFETY
+class GoogleOnceDynamic {
+ public:
+ GoogleOnceDynamic() : state_(GOOGLE_PROTOBUF_ONCE_INIT) { }
+
+ // If this->Init() has not been called before by any thread,
+ // execute (*func_with_arg)(arg) then return.
+ // Otherwise, wait until that prior invocation has finished
+ // executing its function, then return.
+ template<typename T>
+ void Init(void (*func_with_arg)(T*), T* arg) {
+ GoogleOnceInit<T>(&this->state_,
+ func_with_arg,
+ arg);
+ }
+ private:
+ ProtobufOnceType state_;
+};
+
#define GOOGLE_PROTOBUF_DECLARE_ONCE(NAME) \
::google::protobuf::ProtobufOnceType NAME = GOOGLE_PROTOBUF_ONCE_INIT
« no previous file with comments | « third_party/protobuf/src/google/protobuf/stubs/mutex.h ('k') | third_party/protobuf/src/google/protobuf/stubs/once.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698