protos -> hpb namespace transition :: minimal slice

PiperOrigin-RevId: 651111836
pull/17391/head
Hong Shin 7 months ago committed by Copybara-Service
parent 21c545c8c5
commit ab78e2fc1d
  1. 4
      hpb/extension_lock.cc
  2. 4
      hpb/extension_lock.h
  3. 6
      hpb/extension_lock_test.cc
  4. 4
      hpb/hpb.cc
  5. 2
      hpb/repeated_field.h
  6. 4
      hpb/requires.h
  7. 4
      hpb/traits.h
  8. 2
      hpb_generator/tests/test_generated.cc
  9. 5
      protos/protos_extension_lock.h

@ -9,8 +9,8 @@
#include <atomic>
namespace protos::internal {
namespace hpb::internal {
std::atomic<UpbExtensionLocker> upb_extension_locker_global;
} // namespace protos::internal
} // namespace hpb::internal

@ -10,7 +10,7 @@
#include <atomic>
namespace protos::internal {
namespace hpb::internal {
// TODO: Temporary locking api for cross-language
// concurrency issue around extension api that uses lazy promotion
@ -26,6 +26,6 @@ using UpbExtensionLocker = UpbExtensionUnlocker (*)(const void*);
// TODO: Expose as function instead of global.
extern std::atomic<UpbExtensionLocker> upb_extension_locker_global;
} // namespace protos::internal
} // namespace hpb::internal
#endif // PROTOBUF_HPB_EXTENSION_LOCK_H_

@ -49,14 +49,14 @@ std::string GenerateTestData() {
std::mutex m[8];
void unlock_func(const void* msg) { m[absl::HashOf(msg) & 0x7].unlock(); }
::protos::internal::UpbExtensionUnlocker lock_func(const void* msg) {
::hpb::internal::UpbExtensionUnlocker lock_func(const void* msg) {
m[absl::HashOf(msg) & 0x7].lock();
return &unlock_func;
}
void TestConcurrentExtensionAccess(::protos::ExtensionRegistry registry) {
::protos::internal::upb_extension_locker_global.store(
&lock_func, std::memory_order_release);
::hpb::internal::upb_extension_locker_global.store(&lock_func,
std::memory_order_release);
const std::string payload = GenerateTestData();
TestModel parsed_model =
::protos::Parse<TestModel>(payload, registry).value();

@ -83,6 +83,10 @@ absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc
namespace internal {
using ::hpb::internal::upb_extension_locker_global;
using ::hpb::internal::UpbExtensionLocker;
using ::hpb::internal::UpbExtensionUnlocker;
upb_ExtensionRegistry* GetUpbExtensions(
const ExtensionRegistry& extension_registry) {
return extension_registry.registry_;

@ -37,7 +37,7 @@ namespace internal {
// upb_Array* for the message when the RepeatedFieldProxy is constructed.
template <class T>
class RepeatedFieldProxyBase {
using Array = add_const_if_T_is_const<T, upb_Array>;
using Array = hpb::internal::add_const_if_T_is_const<T, upb_Array>;
public:
explicit RepeatedFieldProxyBase(Array* arr, upb_Arena* arena)

@ -2,7 +2,7 @@
#define PROTOBUF_HPB_REQUIRES_H_
#include <type_traits>
namespace protos::internal {
namespace hpb::internal {
// Ports C++20 `requires` to C++17.
// C++20 ideal:
// if constexpr (requires { t.foo(); }) { ... }
@ -12,6 +12,6 @@ template <typename... T, typename F>
constexpr bool Requires(F) {
return std::is_invocable_v<F, T...>;
}
} // namespace protos::internal
} // namespace hpb::internal
#endif // PROTOBUF_HPB_REQUIRES_H_

@ -10,12 +10,12 @@
#include <type_traits>
namespace protos::internal {
namespace hpb::internal {
template <typename T, typename T2>
using add_const_if_T_is_const =
std::conditional_t<std::is_const_v<T>, const T2, T2>;
} // namespace protos::internal
} // namespace hpb::internal
#endif // PROTOBUF_HPB_TRAITS_H_

@ -30,7 +30,7 @@
namespace {
using ::protos::internal::Requires;
using ::hpb::internal::Requires;
using ::protos_generator::test::protos::ChildModel1;
using ::protos_generator::test::protos::container_ext;
using ::protos_generator::test::protos::ContainerExtension;

@ -8,4 +8,9 @@
#ifndef UPB_PROTOS_PROTOS_EXTENSION_LOCK_H_
#define UPB_PROTOS_PROTOS_EXTENSION_LOCK_H_
#include "google/protobuf/hpb/extension_lock.h"
namespace protos::internal {
using hpb::internal::upb_extension_locker_global;
using hpb::internal::UpbExtensionLocker;
using hpb::internal::UpbExtensionUnlocker;
} // namespace protos::internal
#endif
Loading…
Cancel
Save