Skip to content

Commit ae0b703

Browse files
committed
move mutex
1 parent 1fb6499 commit ae0b703

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

wasp/wasp.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,13 @@ func (g *Generator) runExecuteLoop() {
378378
g.currentSegmentMu.Unlock()
379379
// we start all vus once
380380
vus := g.stats.CurrentVUs.Load()
381+
g.vusMu.Lock()
381382
for i := 0; i < int(vus); i++ {
382383
inst := g.vu.Clone(g)
383384
g.runVU(inst)
384-
g.vusMu.Lock()
385385
g.vus = append(g.vus, inst)
386-
g.vusMu.Unlock()
387386
}
387+
g.vusMu.Unlock()
388388
}
389389
}
390390

@@ -512,22 +512,20 @@ func (g *Generator) processSegment() bool {
512512
if oldVUs == newVUs {
513513
return false
514514
}
515+
g.vusMu.Lock()
515516
if oldVUs > g.currentSegment.From {
516517
for i := 0; i < vusToSpawn; i++ {
517-
g.vusMu.Lock()
518518
g.vus[i].Stop(g)
519-
g.vusMu.Unlock()
520519
}
521520
g.vus = g.vus[vusToSpawn:]
522521
} else {
523522
for i := 0; i < vusToSpawn; i++ {
524523
inst := g.vu.Clone(g)
525524
g.runVU(inst)
526-
g.vusMu.Lock()
527525
g.vus = append(g.vus, inst)
528-
g.vusMu.Unlock()
529526
}
530527
}
528+
g.vusMu.Unlock()
531529
}
532530
return false
533531
}
@@ -632,9 +630,9 @@ func (g *Generator) pacedCall() {
632630
if !g.Stats().RunStarted.Load() {
633631
return
634632
}
635-
//if g.rl.Load() == nil {
636-
// return
637-
//}
633+
if g.rl.Load() == nil {
634+
return
635+
}
638636
(*g.rl.Load()).Take()
639637
if g.stats.RunPaused.Load() {
640638
return

0 commit comments

Comments
 (0)