public void ReturnToPool(ICounterItem item) { if (item is CounterItem <T> value) { foreach (var lVal in value.Values) { CounterItemValue <T> .Store(lVal); } CounterItem <T> .Store(value); } }
public static void Store(CounterItem <T> item) { item.Environment = null; item.Application = null; item.Category = null; item.Name = null; item.Type = CounterType.Cumulative; item.Level = CounterLevel.User; item.Kind = CounterKind.Unknown; item.Unit = CounterUnit.Unknown; item.Values = null; ReferencePool <CounterItem <T> > .Shared.Store(item); }
ICounterItem ICounterReader.Take(int items) { if (_counterValues.Count == 0) { return(null); } var lstItems = new List <CounterItemValue <T> >(); var itemIdx = 0; while (itemIdx < items && _counterValues.TryTake(out var item)) { if (item == _lastValue) { lock (_valueLock) { _lastValue = null; } } lstItems.Add(item); itemIdx++; } return(CounterItem <T> .Retrieve(Category, Name, Type, Level, Kind, Unit, lstItems)); }