Skip to content

Commit 56fe285

Browse files
yulin-liYulin Li
andauthored
make it work with deque0.2 and go 1.18 (#64)
* make it work with deque0.2 and go 1.18 * typos Co-authored-by: Yulin Li <Yulin.Li@microsoft.com>
1 parent c38099e commit 56fe285

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/gammazero/workerpool
22

33
require (
4-
github.com/gammazero/deque v0.1.0
4+
github.com/gammazero/deque v0.2.0
55
go.uber.org/goleak v1.1.10
66
)
77

8-
go 1.15
8+
go 1.18

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3-
github.com/gammazero/deque v0.1.0 h1:f9LnNmq66VDeuAlSAapemq/U7hJ2jpIWa4c09q8Dlik=
4-
github.com/gammazero/deque v0.1.0/go.mod h1:KQw7vFau1hHuM8xmI9RbgKFbAsQFWmBpqQ2KenFLk6M=
5-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
3+
github.com/gammazero/deque v0.2.0 h1:SkieyNB4bg2/uZZLxvya0Pq6diUlwx7m2TeT7GAIWaA=
4+
github.com/gammazero/deque v0.2.0/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU=
65
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
76
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
8-
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
97
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
108
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
119
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -27,7 +25,6 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q
2725
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
2826
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2927
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
30-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
3128
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3229
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
3330
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

workerpool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type WorkerPool struct {
4747
workerQueue chan func()
4848
stoppedChan chan struct{}
4949
stopSignal chan struct{}
50-
waitingQueue deque.Deque
50+
waitingQueue deque.Deque[func()]
5151
stopLock sync.Mutex
5252
stopOnce sync.Once
5353
stopped bool
@@ -271,7 +271,7 @@ func (p *WorkerPool) processWaitingQueue() bool {
271271
return false
272272
}
273273
p.waitingQueue.PushBack(task)
274-
case p.workerQueue <- p.waitingQueue.Front().(func()):
274+
case p.workerQueue <- p.waitingQueue.Front():
275275
// A worker was ready, so gave task to worker.
276276
p.waitingQueue.PopFront()
277277
}
@@ -295,7 +295,7 @@ func (p *WorkerPool) killIdleWorker() bool {
295295
func (p *WorkerPool) runQueuedTasks() {
296296
for p.waitingQueue.Len() != 0 {
297297
// A worker is ready, so give task to worker.
298-
p.workerQueue <- p.waitingQueue.PopFront().(func())
298+
p.workerQueue <- p.waitingQueue.PopFront()
299299
atomic.StoreInt32(&p.waiting, int32(p.waitingQueue.Len()))
300300
}
301301
}

0 commit comments

Comments
 (0)