1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2023 Google LLC. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #ifndef PROTOBUF_HPB_EXTENSION_LOCK_H_ 9 #define PROTOBUF_HPB_EXTENSION_LOCK_H_ 10 11 #include <atomic> 12 13 namespace hpb::internal { 14 15 // TODO: Temporary locking api for cross-language 16 // concurrency issue around extension api that uses lazy promotion 17 // from unknown data to upb_MiniTableExtension. Will be replaced by 18 // a core runtime solution in the future. 19 // 20 // Any api(s) using unknown or extension data (GetOrPromoteExtension, 21 // Serialize and others) call lock/unlock to provide a way for 22 // mixed language implementations to avoid race conditions) 23 using UpbExtensionUnlocker = void (*)(const void*); 24 using UpbExtensionLocker = UpbExtensionUnlocker (*)(const void*); 25 26 // TODO: Expose as function instead of global. 27 extern std::atomic<UpbExtensionLocker> upb_extension_locker_global; 28 29 } // namespace hpb::internal 30 31 #endif // PROTOBUF_HPB_EXTENSION_LOCK_H_ 32