Skip to content

Commit 59289d1

Browse files
committed
Move reflect fn value out of loop
1 parent bb992d0 commit 59289d1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
module github.com/vardius/worker-pool
2+
3+
go 1.12

pool.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ func (p *pool) Start(maxWorkers int, fn interface{}) error {
3939
return fmt.Errorf("Can not start already stopped worker")
4040
}
4141

42+
h := reflect.ValueOf(fn)
4243
for i := 1; i <= maxWorkers; i++ {
43-
h := reflect.ValueOf(fn)
44-
4544
go func() {
4645
for args := range p.queue {
4746
h.Call(args)

0 commit comments

Comments
 (0)