Skip to content

Commit

Permalink
refactor: unify the block handling style of Do() and DoMulti()
Browse files Browse the repository at this point in the history
  • Loading branch information
rueian committed Jan 23, 2024
1 parent eb3729b commit 549f23f
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,6 @@ func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {

isOptIn := multi[0].IsOptIn() // len(multi) > 0 should have already been checked by upper layer
noReply := 0
isBlock := false

for _, cmd := range multi {
if cmd.NoReply() {
Expand All @@ -910,23 +909,19 @@ func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {

for _, cmd := range multi {
if cmd.IsBlock() {
isBlock = true
atomic.AddInt32(&p.blcksig, 1)
defer func() {
for _, r := range resp.s {
if r.err != nil {
return
}
}
atomic.AddInt32(&p.blcksig, -1)
}()
break
}
}

if isBlock {
atomic.AddInt32(&p.blcksig, 1)
defer func() {
for _, r := range resp.s {
if r.err != nil {
return
}
}
atomic.AddInt32(&p.blcksig, -1)
}()
}

waits := atomic.AddInt32(&p.waits, 1) // if this is 1, and background worker is not started, no need to queue
state := atomic.LoadInt32(&p.state)

Expand Down

0 comments on commit 549f23f

Please sign in to comment.