• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeltyPlayer / MeltyTool / 26548448806

28 May 2026 01:11AM UTC coverage: 41.227% (-0.2%) from 41.395%
26548448806

push

github

web-flow
Specified the version for lcov merger since the newer one doesn't work for whatever reason.

7037 of 19097 branches covered (36.85%)

Branch coverage included in aggregate %.

30027 of 70806 relevant lines covered (42.41%)

61608.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/FinModelUtility/Fin/Fin/src/data/ReferenceCountCacheDictionary.cs
1
using System;
2
using System.Collections.Concurrent;
3
using System.Collections.Generic;
4

5
namespace fin.data;
6

7
public interface IReferenceCountCacheDictionary<in TKey, out TValue> {
8
  public TValue GetAndIncrement(TKey key);
9
  public void DecrementAndMaybeDispose(TKey key);
10
}
11

12
public sealed class ReferenceCountCacheDictionary<TKey, TValue>(
×
13
    Func<TKey, TValue> createHandler,
×
14
    Action<TKey, TValue>? disposeHandler = null,
×
15
    Action<int>? countChangedHandler = null)
×
16
    : IReferenceCountCacheDictionary<TKey, TValue>
17
    where TKey : notnull {
18
  private readonly ConcurrentDictionary<TKey, (TValue value, int count)> impl_
×
19
      = new();
×
20

21
  public TValue GetAndIncrement(TKey key) {
×
22
    var valueAndCount = this.impl_.GetOrAdd(key, _ => (createHandler(key), 0));
×
23
    valueAndCount.count++;
×
24

25
    if (valueAndCount.count == 1) {
×
26
      countChangedHandler?.Invoke(this.impl_.Count);
×
27
    }
×
28

29
    return valueAndCount.value;
×
30
  }
×
31

32
  public void DecrementAndMaybeDispose(TKey key) {
×
33
    if (this.impl_.TryGetValue(key, out var valueAndCount)) {
×
34
      if (--valueAndCount.count <= 0) {
×
35
        this.impl_.Remove(key, out _);
×
36
        disposeHandler?.Invoke(key, valueAndCount.value);
×
37

38
        countChangedHandler?.Invoke(this.impl_.Count);
×
39
      }
×
40
    }
×
41
  }
×
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc