Skip to content

Commit

Permalink
refactor: remove unnecessary atomic operator
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 15, 2024
1 parent 26145b0 commit 2eae79f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ext/pkg/control/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/siyul-park/uniflow/pkg/spec"
"github.com/siyul-park/uniflow/pkg/types"
"sync"
"sync/atomic"
)

// RetryNodeSpec defines the configuration for RetryNode.
Expand Down Expand Up @@ -102,19 +101,17 @@ func (n *RetryNode) forward(proc *process.Process) {
return
}

actual, _ := attempts.LoadOrStore(inPck, &atomic.Uint32{})
count := actual.(*atomic.Uint32)
actual, _ := attempts.LoadOrStore(inPck, 0)
count := actual.(int)

for {
v := count.Load()

if int(v) == n.limit {
if count == n.limit {
n.tracer.Transform(inPck, backPck)
n.tracer.Write(errWriter, backPck)
return
}

if count.CompareAndSwap(v, v+1) {
if attempts.CompareAndSwap(inPck, count, count+1) {
break
}
}
Expand Down

0 comments on commit 2eae79f

Please sign in to comment.