Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public RepeatedFailuresOverTimeCircuitBreaker(string name, TimeSpan timeToWaitBe

public void Success()
{
var oldValue = Interlocked.Exchange(ref failureCount, 0);

if (oldValue == 0)
// If the failure count was already zero, replace it with zero (no change) and then return original
if (Interlocked.CompareExchange(ref failureCount, 0, 0) == 0)
Copy link
Contributor

@awright18 awright18 Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would solve both problems.

//if there have been no failures previously then return
if(Interlocked.Read(ref failureCount) == 0 )
{
	return;
}
else //if there were previous failures then it's ok to disarm now.
{
   if(Interlocked.Read(ref failureCount) > 0) //not sure if this check is necessary or not.
   {
	  Interlocked.Exchange(ref failureCount, 0);
   }
}

{
return;
}
Expand Down