Skip to content

Commit

Permalink
workerpool
Browse files Browse the repository at this point in the history
- Revert workerpool to v1.0.0
  - The new Pause() method appears to be causing issues
  • Loading branch information
matthewoestreich committed Oct 11, 2020
1 parent b774118 commit b7758cb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/oze4/workerpoolxt
go 1.15

require (
github.com/gammazero/workerpool v1.1.0
github.com/gammazero/workerpool v1.0.0
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
Expand Down
20 changes: 15 additions & 5 deletions workerpoolxt_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package workerpoolxt

import (
"sync"
//"reflect"
"context"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -42,10 +42,20 @@ func TestOverflow(t *testing.T) {

func TestStopRace(t *testing.T) {
wp := New(20, time.Duration(time.Second*10))
workRelChan := make(chan struct{})

// Start and pause all workers.
ctx, cancel := context.WithCancel(context.Background())
wp.Pause(ctx)
var started sync.WaitGroup
started.Add(20)

// Start workers, and have them all wait on a channel before completing.
for i := 0; i < 20; i++ {
wp.Submit(func() {
started.Done()
<-workRelChan
})
}

started.Wait()

const doneCallers = 5
stopDone := make(chan struct{}, doneCallers)
Expand All @@ -62,7 +72,7 @@ func TestStopRace(t *testing.T) {
default:
}

cancel()
close(workRelChan)

timeout := time.After(time.Second)
for i := 0; i < doneCallers; i++ {
Expand Down

0 comments on commit b7758cb

Please sign in to comment.