Skip to content

Commit

Permalink
more explicit preemption in parallel test
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates committed Mar 4, 2024
1 parent 1fc3f0d commit b0f7a95
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package parallel

import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -148,9 +148,9 @@ func testLimitedGroupMaxConcurrency(t *testing.T, name string, g Executor, limit
// All the workers we *expect* to see have shown up now. Throw away all
// the poison pills in the ops queue
for poisonPill := range g.(*limitedGroup).ops {
time.Sleep(0) // Trigger preemption as much as we can
runtime.Gosched() // Trigger preemption as much as we can
assert.NotNil(t, poisonPill)
time.Sleep(0) // Trigger preemption as much as we can
runtime.Gosched() // Trigger preemption as much as we can
}
blocker.Done() // unblock the workers
if shouldSucceed {
Expand Down

0 comments on commit b0f7a95

Please sign in to comment.