Line data Source code
1 : #pragma once 2 : 3 : #include <cstdint> 4 : #include <memory> 5 : 6 : #include "envoy/common/pure.h" 7 : 8 : namespace Envoy { 9 : /** 10 : * Generic interface for all MutexTracer implementations. Any MutexTracer should initialize itself 11 : * with absl::RegisterMutexTracer() at initialization, record statistics, and deliver those 12 : * statistics in a thread-safe manner. 13 : */ 14 : class MutexTracer { 15 : public: 16 0 : virtual ~MutexTracer() = default; 17 : 18 : /** 19 : * @return resets the captured statistics. 20 : */ 21 : virtual void reset() PURE; 22 : 23 : /** 24 : * @return the number of experienced mutex contentions. 25 : */ 26 : virtual int64_t numContentions() const PURE; 27 : 28 : /** 29 : * @return the length of the ongoing wait cycle. Note that the wait cycles are not 30 : * guaranteed to correspond to core clock frequency, as per absl::base_internal::CycleClock. 31 : */ 32 : virtual int64_t currentWaitCycles() const PURE; 33 : 34 : /** 35 : * @return the cumulative length of all experienced wait cycles. See the above note on wait cycles 36 : * v. core clock frequency. 37 : */ 38 : virtual int64_t lifetimeWaitCycles() const PURE; 39 : }; 40 : 41 : } // namespace Envoy