Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 07cea11

Browse files
authored
Add an ABSL_ prefix to thread_annotation.h macros. (#432)
This is a change Abseil is making on their end. Also un-pin Abseil dep with CMake back to master branch.
1 parent 7ea7e73 commit 07cea11

File tree

15 files changed

+91
-86
lines changed

15 files changed

+91
-86
lines changed

cmake/OpenCensusDeps.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ FetchContent_Declare(
2121
FetchContent_Declare(
2222
abseil
2323
GIT_REPOSITORY https://github.com/abseil/abseil-cpp
24-
GIT_TAG 2c8421e1c6cef0da9e8a20b01c15256ec9ec116d)
24+
GIT_TAG master)
2525
FetchContent_Declare(
2626
prometheus
2727
GIT_REPOSITORY https://github.com/jupp0r/prometheus-cpp

opencensus/common/internal/random.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class Generator {
3131
Generator() : rng_(absl::GetCurrentTimeNanos()) {}
3232
explicit Generator(uint64_t seed) : rng_(seed) {}
3333

34-
uint64_t Random64() LOCKS_EXCLUDED(mu_);
34+
uint64_t Random64() ABSL_LOCKS_EXCLUDED(mu_);
3535

3636
private:
3737
friend class Random;
3838

3939
absl::Mutex mu_;
40-
std::mt19937_64 rng_ GUARDED_BY(mu_);
40+
std::mt19937_64 rng_ ABSL_GUARDED_BY(mu_);
4141
};
4242

4343
class Random {

opencensus/exporters/stats/stackdriver/internal/stackdriver_exporter.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Handler : public ::opencensus::stats::StatsExporter::Handler {
5353
void ExportViewData(
5454
const std::vector<std::pair<opencensus::stats::ViewDescriptor,
5555
opencensus::stats::ViewData>>& data)
56-
LOCKS_EXCLUDED(mu_) override;
56+
ABSL_LOCKS_EXCLUDED(mu_) override;
5757

5858
private:
5959
// Registers 'descriptor' with Stackdriver if no view by that name has been
@@ -62,12 +62,13 @@ class Handler : public ::opencensus::stats::StatsExporter::Handler {
6262
// successful, and false if the registration fails or the name has already
6363
// been registered with different parameters.
6464
bool MaybeRegisterView(const opencensus::stats::ViewDescriptor& descriptor,
65-
bool add_task_label) EXCLUSIVE_LOCKS_REQUIRED(mu_);
65+
bool add_task_label)
66+
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
6667

6768
const StackdriverOptions opts_;
6869
mutable absl::Mutex mu_;
6970
std::unordered_map<std::string, opencensus::stats::ViewDescriptor>
70-
registered_descriptors_ GUARDED_BY(mu_);
71+
registered_descriptors_ ABSL_GUARDED_BY(mu_);
7172
};
7273

7374
StackdriverOptions SetOptionDefaults(StackdriverOptions&& o) {

opencensus/stats/internal/delta_producer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ class DeltaProducer final {
7979
void AddBoundaries(uint64_t index, const BucketBoundaries& boundaries);
8080

8181
void Record(std::initializer_list<Measurement> measurements,
82-
opencensus::tags::TagMap tags) LOCKS_EXCLUDED(delta_mu_);
82+
opencensus::tags::TagMap tags) ABSL_LOCKS_EXCLUDED(delta_mu_);
8383

8484
// Flushes the active delta and blocks until it is harvested.
85-
void Flush() LOCKS_EXCLUDED(delta_mu_, harvester_mu_);
85+
void Flush() ABSL_LOCKS_EXCLUDED(delta_mu_, harvester_mu_);
8686

8787
private:
8888
DeltaProducer();
@@ -92,9 +92,9 @@ class DeltaProducer final {
9292
// ConsumeLastDelta so that Record() is blocked for as little time as
9393
// possible. SwapDeltas should never be called without then calling
9494
// ConsumeLastDelta--otherwise the delta will be lost.
95-
void SwapDeltas() EXCLUSIVE_LOCKS_REQUIRED(delta_mu_, harvester_mu_);
96-
void ConsumeLastDelta() EXCLUSIVE_LOCKS_REQUIRED(harvester_mu_)
97-
LOCKS_EXCLUDED(delta_mu_);
95+
void SwapDeltas() ABSL_EXCLUSIVE_LOCKS_REQUIRED(delta_mu_, harvester_mu_);
96+
void ConsumeLastDelta() ABSL_EXCLUSIVE_LOCKS_REQUIRED(harvester_mu_)
97+
ABSL_LOCKS_EXCLUDED(delta_mu_);
9898

9999
// Loops flushing the active delta (calling SwapDeltas and ConsumeLastDelta())
100100
// every harvest_interval_.
@@ -112,16 +112,16 @@ class DeltaProducer final {
112112
// The BucketBoundaries of each registered view with Distribution aggregation,
113113
// by measure. Array indices in the outer array correspond to measure indices.
114114
std::vector<std::vector<BucketBoundaries>> registered_boundaries_
115-
GUARDED_BY(delta_mu_);
116-
Delta active_delta_ GUARDED_BY(delta_mu_);
115+
ABSL_GUARDED_BY(delta_mu_);
116+
Delta active_delta_ ABSL_GUARDED_BY(delta_mu_);
117117

118118
// Guards the last_delta_; acquired by the main thread when triggering a
119119
// flush.
120-
mutable absl::Mutex harvester_mu_ ACQUIRED_AFTER(delta_mu_);
120+
mutable absl::Mutex harvester_mu_ ABSL_ACQUIRED_AFTER(delta_mu_);
121121
// TODO: consider making this a lockless queue to avoid blocking the main
122122
// thread when calling a flush during harvesting.
123-
Delta last_delta_ GUARDED_BY(harvester_mu_);
124-
std::thread harvester_thread_ GUARDED_BY(harvester_mu_);
123+
Delta last_delta_ ABSL_GUARDED_BY(harvester_mu_);
124+
std::thread harvester_thread_ ABSL_GUARDED_BY(harvester_mu_);
125125
};
126126

127127
} // namespace stats

opencensus/stats/internal/measure_registry_impl.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ class MeasureRegistryImpl {
3939
template <typename MeasureT>
4040
Measure<MeasureT> Register(absl::string_view name,
4141
absl::string_view description,
42-
absl::string_view units) LOCKS_EXCLUDED(mu_);
42+
absl::string_view units) ABSL_LOCKS_EXCLUDED(mu_);
4343

4444
const MeasureDescriptor& GetDescriptorByName(absl::string_view name) const
45-
LOCKS_EXCLUDED(mu_);
45+
ABSL_LOCKS_EXCLUDED(mu_);
4646

4747
MeasureDouble GetMeasureDoubleByName(absl::string_view name) const
48-
LOCKS_EXCLUDED(mu_);
48+
ABSL_LOCKS_EXCLUDED(mu_);
4949
MeasureInt64 GetMeasureInt64ByName(absl::string_view name) const
50-
LOCKS_EXCLUDED(mu_);
50+
ABSL_LOCKS_EXCLUDED(mu_);
5151

5252
// The following methods are for internal use by the library, and not exposed
5353
// in the public MeasureRegistry.
54-
uint64_t GetIdByName(absl::string_view name) const LOCKS_EXCLUDED(mu_);
54+
uint64_t GetIdByName(absl::string_view name) const ABSL_LOCKS_EXCLUDED(mu_);
5555

5656
template <typename MeasureT>
5757
const MeasureDescriptor& GetDescriptor(Measure<MeasureT> measure) const
58-
LOCKS_EXCLUDED(mu_);
58+
ABSL_LOCKS_EXCLUDED(mu_);
5959

6060
// Measure ids contain a sequential index, a validity bit, and a
6161
// type bit; these functions access the individual parts.
@@ -69,7 +69,7 @@ class MeasureRegistryImpl {
6969
private:
7070
MeasureRegistryImpl() = default;
7171

72-
uint64_t RegisterImpl(MeasureDescriptor descriptor) LOCKS_EXCLUDED(mu_);
72+
uint64_t RegisterImpl(MeasureDescriptor descriptor) ABSL_LOCKS_EXCLUDED(mu_);
7373

7474
static uint64_t CreateMeasureId(uint64_t index, bool is_valid,
7575
MeasureDescriptor::Type type);
@@ -80,9 +80,9 @@ class MeasureRegistryImpl {
8080
// descriptors themselves don't move around when the vector storage moves due
8181
// to resize.
8282
std::vector<std::unique_ptr<MeasureDescriptor>> registered_descriptors_
83-
GUARDED_BY(mu_);
83+
ABSL_GUARDED_BY(mu_);
8484
// A map from measure names to IDs.
85-
std::unordered_map<std::string, uint64_t> id_map_ GUARDED_BY(mu_);
85+
std::unordered_map<std::string, uint64_t> id_map_ ABSL_GUARDED_BY(mu_);
8686
};
8787

8888
template <>

opencensus/stats/internal/stats_exporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void StatsExporterImpl::ClearHandlersForTesting() {
9494
handlers_.clear();
9595
}
9696

97-
void StatsExporterImpl::StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
97+
void StatsExporterImpl::StartExportThread() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
9898
t_ = std::thread(&StatsExporterImpl::RunWorkerLoop, this);
9999
thread_started_ = true;
100100
}

opencensus/stats/internal/stats_exporter_impl.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ class StatsExporterImpl {
5050
private:
5151
StatsExporterImpl() = default;
5252

53-
void StartExportThread() EXCLUSIVE_LOCKS_REQUIRED(mu_);
53+
void StartExportThread() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
5454

5555
// Loops forever, calling Export() every export_interval_.
5656
void RunWorkerLoop();
5757

5858
mutable absl::Mutex mu_;
59-
absl::Duration export_interval_ GUARDED_BY(mu_) = absl::Seconds(10);
59+
absl::Duration export_interval_ ABSL_GUARDED_BY(mu_) = absl::Seconds(10);
6060
std::vector<std::unique_ptr<StatsExporter::Handler>> handlers_
61-
GUARDED_BY(mu_);
62-
std::unordered_map<std::string, std::unique_ptr<View>> views_ GUARDED_BY(mu_);
63-
bool thread_started_ GUARDED_BY(mu_) = false;
64-
std::thread t_ GUARDED_BY(mu_);
61+
ABSL_GUARDED_BY(mu_);
62+
std::unordered_map<std::string, std::unique_ptr<View>> views_
63+
ABSL_GUARDED_BY(mu_);
64+
bool thread_started_ ABSL_GUARDED_BY(mu_) = false;
65+
std::thread t_ ABSL_GUARDED_BY(mu_);
6566
};
6667

6768
} // namespace stats

opencensus/stats/internal/stats_exporter_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct ExportedData {
3838
}
3939

4040
mutable absl::Mutex mu;
41-
std::vector<std::pair<ViewDescriptor, ViewData>> data GUARDED_BY(mu);
41+
std::vector<std::pair<ViewDescriptor, ViewData>> data ABSL_GUARDED_BY(mu);
4242
};
4343

4444
// A mock exporter that assigns exported data to the provided pointer.

opencensus/stats/internal/stats_manager.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class StatsManager final {
6262
const MeasureData& data, absl::Time now);
6363

6464
// Retrieves a copy of the data.
65-
std::unique_ptr<ViewDataImpl> GetData() LOCKS_EXCLUDED(*mu_);
65+
std::unique_ptr<ViewDataImpl> GetData() ABSL_LOCKS_EXCLUDED(*mu_);
6666

6767
const ViewDescriptor& view_descriptor() const { return descriptor_; }
6868

@@ -72,33 +72,33 @@ class StatsManager final {
7272
absl::Mutex* const mu_; // Not owned.
7373
// The number of View objects backed by this ViewInformation, for
7474
// reference-counted GC.
75-
int num_consumers_ GUARDED_BY(*mu_) = 1;
75+
int num_consumers_ ABSL_GUARDED_BY(*mu_) = 1;
7676

7777
// Possible types of stored data.
7878
enum class DataType { kDouble, kUint64, kDistribution, kInterval };
7979
static DataType DataTypeForDescriptor(const ViewDescriptor& descriptor);
8080

81-
ViewDataImpl data_ GUARDED_BY(*mu_);
81+
ViewDataImpl data_ ABSL_GUARDED_BY(*mu_);
8282
};
8383

8484
public:
8585
static StatsManager* Get();
8686

8787
// Merges all data from 'delta' at the present time.
88-
void MergeDelta(const Delta& delta) LOCKS_EXCLUDED(mu_);
88+
void MergeDelta(const Delta& delta) ABSL_LOCKS_EXCLUDED(mu_);
8989

9090
// Adds a measure--this is necessary for views to be added under that measure.
9191
template <typename MeasureT>
92-
void AddMeasure(Measure<MeasureT> measure) LOCKS_EXCLUDED(mu_);
92+
void AddMeasure(Measure<MeasureT> measure) ABSL_LOCKS_EXCLUDED(mu_);
9393

9494
// Returns a handle that can be used to retrieve data for 'descriptor' (which
9595
// may point to a new or re-used ViewInformation).
9696
ViewInformation* AddConsumer(const ViewDescriptor& descriptor)
97-
LOCKS_EXCLUDED(mu_);
97+
ABSL_LOCKS_EXCLUDED(mu_);
9898

9999
// Removes a consumer from the ViewInformation 'handle', and deletes it if
100100
// that was the last consumer.
101-
void RemoveConsumer(ViewInformation* handle) LOCKS_EXCLUDED(mu_);
101+
void RemoveConsumer(ViewInformation* handle) ABSL_LOCKS_EXCLUDED(mu_);
102102

103103
private:
104104
// MeasureInformation stores all ViewInformation objects for a given measure.
@@ -118,7 +118,7 @@ class StatsManager final {
118118
absl::Mutex* const mu_; // Not owned.
119119
// View objects hold a pointer to ViewInformation directly, so we do not
120120
// need fast lookup--lookup is only needed for view removal.
121-
std::vector<std::unique_ptr<ViewInformation>> views_ GUARDED_BY(*mu_);
121+
std::vector<std::unique_ptr<ViewInformation>> views_ ABSL_GUARDED_BY(*mu_);
122122
};
123123

124124
// TODO: PERF: Global synchronization is only needed for adding or
@@ -127,7 +127,7 @@ class StatsManager final {
127127
mutable absl::Mutex mu_;
128128

129129
// All registered measures.
130-
std::vector<MeasureInformation> measures_ GUARDED_BY(mu_);
130+
std::vector<MeasureInformation> measures_ ABSL_GUARDED_BY(mu_);
131131
};
132132

133133
extern template void StatsManager::AddMeasure(MeasureDouble measure);

opencensus/tags/internal/tag_key.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class TagKeyRegistry {
3636
return global_tag_key_registry;
3737
}
3838

39-
TagKey Register(absl::string_view name) LOCKS_EXCLUDED(mu_);
39+
TagKey Register(absl::string_view name) ABSL_LOCKS_EXCLUDED(mu_);
4040

41-
const std::string& TagKeyName(TagKey key) const LOCKS_EXCLUDED(mu_) {
41+
const std::string& TagKeyName(TagKey key) const ABSL_LOCKS_EXCLUDED(mu_) {
4242
absl::ReaderMutexLock l(&mu_);
4343
return *registered_tag_keys_[key.id_];
4444
}
@@ -49,10 +49,10 @@ class TagKeyRegistry {
4949
// are allocated individually so that they don't move around when the vector
5050
// storage moves due to resize.
5151
std::vector<std::unique_ptr<std::string>> registered_tag_keys_
52-
GUARDED_BY(mu_);
52+
ABSL_GUARDED_BY(mu_);
5353
// A map from names to IDs.
5454
// TODO: change to string_view when a suitable hash is available.
55-
std::unordered_map<std::string, uint64_t> id_map_ GUARDED_BY(mu_);
55+
std::unordered_map<std::string, uint64_t> id_map_ ABSL_GUARDED_BY(mu_);
5656
};
5757

5858
TagKey TagKeyRegistry::Register(absl::string_view name) {

0 commit comments

Comments
 (0)