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 af379be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/pkg/cli/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func TestDebugModel_Update(t *testing.T) {
m.Update(tea.KeyMsg{Type: tea.KeyEnter})

data, _ := json.Marshal(types.InterfaceOf(payload))
assert.Contains(t, m.View(), string(data))
assert.Contains(t, m.View(), data)

d.RemoveBreakpoint(d.Breakpoint())
})
Expand Down Expand Up @@ -700,7 +700,7 @@ func TestDebugModel_Update(t *testing.T) {
m.Update(tea.KeyMsg{Type: tea.KeyEnter})

data := fmt.Sprintf("%v", types.InterfaceOf(payload))
assert.Contains(t, m.View(), string(data))
assert.Contains(t, m.View(), data)

d.RemoveBreakpoint(d.Breakpoint())
})
Expand Down Expand Up @@ -763,7 +763,7 @@ func TestDebugModel_Update(t *testing.T) {
m.Update(tea.KeyMsg{Type: tea.KeyEnter})

data := fmt.Sprintf("%v", types.InterfaceOf(payload))
assert.Contains(t, m.View(), string(data))
assert.Contains(t, m.View(), data)

d.RemoveBreakpoint(d.Breakpoint())
})
Expand Down
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 af379be

Please sign in to comment.