Skip to content

Commit a0df11f

Browse files
authored
Tiny: use Load instead of CompareAndSwap for detecting recoveries (dapr#69)
Should be _slightly_ faster Signed-off-by: ItalyPaleAle <[email protected]>
1 parent 4f434eb commit a0df11f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

retry/retry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func NotifyRecover(operation backoff.Operation, b backoff.BackOff, notify backof
159159
return backoff.RetryNotify(func() error {
160160
err := operation()
161161

162-
if err == nil && notified.CompareAndSwap(true, false) {
162+
if err == nil && notified.Load() {
163163
recovered()
164164
}
165165

@@ -178,7 +178,7 @@ func NotifyRecoverWithData[T any](operation backoff.OperationWithData[T], b back
178178
return backoff.RetryNotifyWithData(func() (T, error) {
179179
res, err := operation()
180180

181-
if err == nil && notified.CompareAndSwap(true, false) {
181+
if err == nil && notified.Load() {
182182
recovered()
183183
}
184184

0 commit comments

Comments
 (0)