Skip to content

Commit

Permalink
fix: introduce dedicated lock object (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaVetnic authored Mar 8, 2024
1 parent fd19aa3 commit c1113d1
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Identity
private readonly List<IndividualQuota> _individualQuotas;
private readonly List<MetricStatus> _metricStatuses;

private readonly object _latestExhaustionDateLock = new();

// ReSharper disable once UnusedMember.Local
private Identity()
{
Expand Down Expand Up @@ -120,7 +122,7 @@ await Parallel.ForEachAsync(quotasForMetric, cancellationToken, async (quota, _)

var quotaExhaustion = quota.CalculateExhaustion(newUsage);

lock (latestExhaustionDate)
lock (_latestExhaustionDateLock)
{
if (quotaExhaustion > latestExhaustionDate)
latestExhaustionDate = quotaExhaustion;
Expand Down

0 comments on commit c1113d1

Please sign in to comment.