11 #ifndef hifi_gpu_Metric_h
12 #define hifi_gpu_Metric_h
23 std::atomic<T> _value { 0 };
24 std::atomic<T> _maximum { 0 };
43 void set(T newValue) {
51 auto total = ++_value;
52 if (total > _maximum.load()) {
71 void update(T prevValue, T newValue) {
72 if (prevValue == newValue) {
75 if (newValue > prevValue) {
76 auto total = _value.fetch_add(newValue - prevValue);
77 if (total > _maximum.load()) {
81 _value.fetch_sub(prevValue - newValue);
94 using ContextMetricCount = Metric<uint32_t>;
95 using ContextMetricSize = Metric<Size>;
void set(T newValue)
Set metric to a new value.
Definition: Metric.h:43
void update(T prevValue, T newValue)
Atomically subtract previous value from the metric and add new one.
Definition: Metric.h:71
void decrement()
Decrement stored value by one.
Definition: Metric.h:60
T getMaximum()
Definition: Metric.h:35
T getValue()
Definition: Metric.h:30
void increment()
Increment stored value by one.
Definition: Metric.h:50
void reset()
Resets current metric value and maximum value to zero.
Definition: Metric.h:88