Skip to content

Commit 652b9c7

Browse files
honglookercopybara-github
authored andcommitted
Internal Change
PiperOrigin-RevId: 793650386
1 parent be95d77 commit 652b9c7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

hpb/internal/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ cc_test(
7575
"//hpb_generator/tests:test_model_hpb_proto",
7676
"//upb/mem",
7777
"//upb/mini_table",
78+
"@abseil-cpp//absl/base:core_headers",
7879
"@abseil-cpp//absl/hash",
7980
"@abseil-cpp//absl/log:absl_check",
8081
"@googletest//:gtest",

hpb/internal/message_lock_test.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <thread>
1414

1515
#include <gtest/gtest.h>
16+
#include "absl/base/thread_annotations.h"
1617
#include "absl/hash/hash.h"
1718
#include "absl/log/absl_check.h"
1819
#include "hpb_generator/tests/test_model.hpb.h"
@@ -49,8 +50,13 @@ std::string GenerateTestData() {
4950
}
5051

5152
std::mutex m[8];
52-
void unlock_func(const void* msg) { m[absl::HashOf(msg) & 0x7].unlock(); }
53-
::hpb::internal::UpbExtensionUnlocker lock_func(const void* msg) {
53+
void unlock_func(const void* msg)
54+
ABSL_UNLOCK_FUNCTION(m[absl::HashOf(msg) & 0x7]) {
55+
m[absl::HashOf(msg) & 0x7].unlock();
56+
}
57+
58+
::hpb::internal::UpbExtensionUnlocker lock_func(const void* msg)
59+
ABSL_EXCLUSIVE_LOCK_FUNCTION(m[absl::HashOf(msg) & 0x7]) {
5460
m[absl::HashOf(msg) & 0x7].lock();
5561
return &unlock_func;
5662
}

0 commit comments

Comments
 (0)