private static void SetupCounter(ref AtomicValue <PerformanceCounter> counter, string counterCategory, string counterName) { if (_categoryReady.TryTake()) { SetupCategory(); } if (counter.Value == null) { lock (counter) if (counter.Value == null) { counter.Value = new PerformanceCounter(counterCategory, counterName, false); } } }
private static void setupAndIncrement(ref AtomicValue <PerformanceCounter> counter, string counterName, long?value = null, bool raw_value = false) { if (Diagnostics.CassandraPerformanceCountersEnabled) { SetupCounter(ref counter, CassandraCountersCategory, counterName); if (value != null) { if (raw_value) { counter.Value.RawValue = (long)value; } else { counter.Value.IncrementBy((long)value); } } else { counter.Value.Increment(); } } }