Skip to content

Commit

Permalink
Replace any with interface{}
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfezh committed Jun 30, 2022
1 parent 2209084 commit fa93833
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func main() {
fmt.Printf("finish all tasks.\n")

// Use the common pool, with args.
calcFunc := func(args ...any) {
calcFunc := func(args ...interface{}) {
i := args[0].(int32)
myAdd(i)
wg.Done()
Expand Down
2 changes: 1 addition & 1 deletion ants.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func Submit(task func()) error {
}

// Submit submits a task with arguments to pool.
func SubmitWithArgs(task func(args ...any), args ...any) error {
func SubmitWithArgs(task func(args ...interface{}), args ...interface{}) error {
return defaultAntsPool.SubmitWithArgs(task, args...)

Check warning on line 109 in ants.go

View check run for this annotation

Codecov / codecov/patch

ants.go#L108-L109

Added lines #L108 - L109 were not covered by tests
}

Expand Down
2 changes: 1 addition & 1 deletion examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {
fmt.Printf("finish all tasks.\n")

// Use the common pool, with args.
calcFunc := func(args ...any) {
calcFunc := func(args ...interface{}) {
i := args[0].(int32)
myAdd(i)
wg.Done()
Expand Down
4 changes: 2 additions & 2 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ func NewPool(size int, options ...Option) (*Pool, error) {
// Pool.Submit() call once the current Pool runs out of its capacity, and to avoid this,
// you should instantiate a Pool with ants.WithNonblocking(true).
func (p *Pool) Submit(task func()) error {
return p.SubmitWithArgs(func(args ...any) {
return p.SubmitWithArgs(func(args ...interface{}) {
task()
})
}

// Submit submits a task with arguments to this pool.
func (p *Pool) SubmitWithArgs(task func(args ...any), args ...any) error {
func (p *Pool) SubmitWithArgs(task func(args ...interface{}), args ...interface{}) error {
if p.IsClosed() {
return ErrPoolClosed
}
Expand Down
4 changes: 2 additions & 2 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (

// goTask is the task with a function and arguments
type goTask struct {
task func(args ...any)
args []any
task func(args ...interface{})
args []interface{}
}

// goWorker is the actual executor who runs the tasks,
Expand Down

0 comments on commit fa93833

Please sign in to comment.