diff options
author | ncteisen <ncteisen@gmail.com> | 2017-11-17 13:39:01 -0800 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-11-17 13:39:01 -0800 |
commit | c4dd9cfe1893081b6783213f96d2b72b7b02d165 (patch) | |
tree | ac9180be073277cf77e5df91f08b048e321beb31 /src/core/lib | |
parent | b2aa06ae990e82b5c7f573f282b7bcfef7093d54 (diff) |
reviewer feedback
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/debug/trace.cc | 16 | ||||
-rw-r--r-- | src/core/lib/debug/trace.h | 19 |
2 files changed, 13 insertions, 22 deletions
diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index 04558fd91e..4c63983bdc 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -29,13 +29,7 @@ int grpc_tracer_set_enabled(const char* name, int enabled); namespace grpc_core { -TraceFlagList* TraceFlagList::instance_ = nullptr; - -TraceFlagList* TraceFlagList::Get() { - if (instance_ == nullptr) - instance_ = static_cast<TraceFlagList*>(gpr_malloc(sizeof(TraceFlagList))); - return instance_; -} +TraceFlag* TraceFlagList::root_tracer_ = nullptr; bool TraceFlagList::Set(const char* name, bool enabled) { TraceFlag* t; @@ -83,7 +77,7 @@ void TraceFlagList::LogAllTracers() { // Flags register themselves on the list during construction TraceFlag::TraceFlag(bool default_enabled, const char* name) : name_(name), value_(default_enabled) { - TraceFlagList::Get()->Add(this); + TraceFlagList::Add(this); } } // namespace grpc_core @@ -121,9 +115,9 @@ static void parse(const char* s) { for (i = 0; i < nstrings; i++) { if (strings[i][0] == '-') { - grpc_core::TraceFlagList::Get()->Set(strings[i] + 1, false); + grpc_core::TraceFlagList::Set(strings[i] + 1, false); } else { - grpc_core::TraceFlagList::Get()->Set(strings[i], true); + grpc_core::TraceFlagList::Set(strings[i], true); } } @@ -144,5 +138,5 @@ void grpc_tracer_init(const char* env_var) { void grpc_tracer_shutdown(void) {} int grpc_tracer_set_enabled(const char* name, int enabled) { - return grpc_core::TraceFlagList::Get()->Set(name, enabled != 0); + return grpc_core::TraceFlagList::Set(name, enabled != 0); } diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index 8e3a39d173..b58c16f3ca 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -47,25 +47,19 @@ namespace grpc_core { class TraceFlag; class TraceFlagList { public: - static TraceFlagList* Get(); - bool Set(const char* name, bool enabled); - void Add(TraceFlag* flag); + static bool Set(const char* name, bool enabled); + static void Add(TraceFlag* flag); private: - static TraceFlagList* instance_; - void LogAllTracers(); - TraceFlagList() : root_tracer_(nullptr) {} - TraceFlag* root_tracer_; + static void LogAllTracers(); + static TraceFlag* root_tracer_; }; namespace testing { -void grpc_tracer_peer_enable_flag(grpc_core::TraceFlag* flag); +void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag); } class TraceFlag { - friend void grpc_core::testing::grpc_tracer_peer_enable_flag(TraceFlag* flag); - friend class TraceFlagList; - public: TraceFlag(bool default_enabled, const char* name); ~TraceFlag() {} @@ -81,6 +75,9 @@ class TraceFlag { } private: + friend void grpc_core::testing::grpc_tracer_enable_flag(TraceFlag* flag); + friend class TraceFlagList; + void set_enabled(bool enabled) { #ifdef GRPC_THREADSAFE_TRACER gpr_atm_no_barrier_store(&value_, enabled); |