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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // A lock to provide mutual exclusion from internal data that can be modified 61 // A lock to provide mutual exclusion from internal data that can be modified
62 // by *read* operations such as getters (autocreation of message fields and 62 // by *read* operations such as getters (autocreation of message fields and
63 // message extensions, not setting of values). Used to guarantee thread safety 63 // message extensions, not setting of values). Used to guarantee thread safety
64 // for concurrent reads on the message. 64 // for concurrent reads on the message.
65 // NOTE: OSSpinLock may seem like a good fit here but Apple engineers have 65 // NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
66 // pointed out that they are vulnerable to live locking on iOS in cases of 66 // pointed out that they are vulnerable to live locking on iOS in cases of
67 // priority inversion: 67 // priority inversion:
68 // http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ 68 // http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
69 // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.h tml 69 // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.h tml
70 // Use of readOnlySemaphore_ must be prefaced by a call to
71 // GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
72 // readOnlySemaphore_ to be only created when actually needed.
73 dispatch_once_t readOnlySemaphoreCreationOnce_;
70 dispatch_semaphore_t readOnlySemaphore_; 74 dispatch_semaphore_t readOnlySemaphore_;
71 } 75 }
72 76
73 // Gets an extension value without autocreating the result if not found. (i.e. 77 // Gets an extension value without autocreating the result if not found. (i.e.
74 // returns nil if the extension is not set) 78 // returns nil if the extension is not set)
75 - (id)getExistingExtension:(GPBExtensionDescriptor *)extension; 79 - (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
76 80
77 // Returns an array of GPBExtensionDescriptor* for all the extensions currently 81 // Returns an array of GPBExtensionDescriptor* for all the extensions currently
78 // in use on the message. They are sorted by field number. 82 // in use on the message. They are sorted by field number.
79 - (NSArray *)sortedExtensionsInUse; 83 - (NSArray *)sortedExtensionsInUse;
(...skipping 16 matching lines...) Expand all
96 - (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input 100 - (void)mergeDelimitedFromCodedInputStream:(GPBCodedInputStream *)input
97 extensionRegistry: 101 extensionRegistry:
98 (GPBExtensionRegistry *)extensionRegistry; 102 (GPBExtensionRegistry *)extensionRegistry;
99 103
100 - (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data; 104 - (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
101 105
102 @end 106 @end
103 107
104 CF_EXTERN_C_BEGIN 108 CF_EXTERN_C_BEGIN
105 109
110
111 // Call this before using the readOnlySemaphore_. This ensures it is created onl y once.
112 NS_INLINE void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
113 dispatch_once(&self->readOnlySemaphoreCreationOnce_, ^{
114 self->readOnlySemaphore_ = dispatch_semaphore_create(1);
115 });
116 }
117
106 // Returns a new instance that was automatically created by |autocreator| for 118 // Returns a new instance that was automatically created by |autocreator| for
107 // its field |field|. 119 // its field |field|.
108 GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, 120 GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
109 GPBMessage *autocreator, 121 GPBMessage *autocreator,
110 GPBFieldDescriptor *field) 122 GPBFieldDescriptor *field)
111 __attribute__((ns_returns_retained)); 123 __attribute__((ns_returns_retained));
112 124
113 // Returns whether |message| autocreated this message. This is NO if the message 125 // Returns whether |message| autocreated this message. This is NO if the message
114 // was not autocreated by |message| or if it has been mutated since 126 // was not autocreated by |message| or if it has been mutated since
115 // autocreation. 127 // autocreation.
116 BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent); 128 BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent);
117 129
118 // Call this when you mutate a message. It will cause the message to become 130 // Call this when you mutate a message. It will cause the message to become
119 // visible to its autocreator. 131 // visible to its autocreator.
120 void GPBBecomeVisibleToAutocreator(GPBMessage *self); 132 void GPBBecomeVisibleToAutocreator(GPBMessage *self);
121 133
122 // Call this when an array/dictionary is mutated so the parent message that 134 // Call this when an array/dictionary is mutated so the parent message that
123 // autocreated it can react. 135 // autocreated it can react.
124 void GPBAutocreatedArrayModified(GPBMessage *self, id array); 136 void GPBAutocreatedArrayModified(GPBMessage *self, id array);
125 void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary); 137 void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary);
126 138
127 // Clear the autocreator, if any. Asserts if the autocreator still has an 139 // Clear the autocreator, if any. Asserts if the autocreator still has an
128 // autocreated reference to this message. 140 // autocreated reference to this message.
129 void GPBClearMessageAutocreator(GPBMessage *self); 141 void GPBClearMessageAutocreator(GPBMessage *self);
130 142
131 CF_EXTERN_C_END 143 CF_EXTERN_C_END
OLDNEW
« 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