File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -311,11 +311,21 @@ func TestOverflow(t *testing.T) {
311311}
312312
313313func TestStopRace (t * testing.T ) {
314- wp := New (20 )
314+ wp := New (max )
315+ workRelChan := make (chan struct {})
315316
316- // Start and pause all workers.
317- ctx , cancel := context .WithCancel (context .Background ())
318- wp .Pause (ctx )
317+ var started sync.WaitGroup
318+ started .Add (max )
319+
320+ // Start workers, and have them all wait on a channel before completing.
321+ for i := 0 ; i < max ; i ++ {
322+ wp .Submit (func () {
323+ started .Done ()
324+ <- workRelChan
325+ })
326+ }
327+
328+ started .Wait ()
319329
320330 const doneCallers = 5
321331 stopDone := make (chan struct {}, doneCallers )
@@ -332,7 +342,7 @@ func TestStopRace(t *testing.T) {
332342 default :
333343 }
334344
335- cancel ( )
345+ close ( workRelChan )
336346
337347 timeout := time .After (time .Second )
338348 for i := 0 ; i < doneCallers ; i ++ {
You can’t perform that action at this time.
0 commit comments