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

Unified Diff: third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 7 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
« no previous file with comments | « third_party/protobuf/objectivec/GPBMessage.m ('k') | third_party/protobuf/objectivec/GPBProtocolBuffers.m » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h
diff --git a/third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h b/third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h
index b7e24fc9330536cfa8043a58763209a8dad7dffc..478db2cf0f96395915637ab862a0ec2f29a2bc1c 100644
--- a/third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h
+++ b/third_party/protobuf/objectivec/GPBMessage_PackagePrivate.h
@@ -67,6 +67,10 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// priority inversion:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
+ // Use of readOnlySemaphore_ must be prefaced by a call to
+ // GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
+ // readOnlySemaphore_ to be only created when actually needed.
+ dispatch_once_t readOnlySemaphoreCreationOnce_;
dispatch_semaphore_t readOnlySemaphore_;
}
@@ -103,6 +107,14 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
CF_EXTERN_C_BEGIN
+
+// Call this before using the readOnlySemaphore_. This ensures it is created only once.
+NS_INLINE void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
+ dispatch_once(&self->readOnlySemaphoreCreationOnce_, ^{
+ self->readOnlySemaphore_ = dispatch_semaphore_create(1);
+ });
+}
+
// Returns a new instance that was automatically created by |autocreator| for
// its field |field|.
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
« no previous file with comments | « third_party/protobuf/objectivec/GPBMessage.m ('k') | third_party/protobuf/objectivec/GPBProtocolBuffers.m » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698