chore: reorganize the structure of internal packages

This commit is contained in:
Andy Pan 2023-02-19 22:46:33 +08:00
parent 88d2454bbb
commit 711cad9624
4 changed files with 11 additions and 12 deletions

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package internal
package sync
import (
"runtime"

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package internal
package sync
import (
"runtime"
@ -14,12 +14,11 @@ import (
/*
Benchmark result for three types of locks:
goos: darwin
goarch: amd64
pkg: github.com/panjf2000/ants/v2/internal
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkMutex-12 20549502 71.84 ns/op 0 B/op 0 allocs/op
BenchmarkSpinLock-12 58629697 20.02 ns/op 0 B/op 0 allocs/op
BenchmarkBackOffSpinLock-12 72523454 15.74 ns/op 0 B/op 0 allocs/op
goarch: arm64
pkg: github.com/panjf2000/ants/v2/internal/sync
BenchmarkMutex-10 10452573 111.1 ns/op 0 B/op 0 allocs/op
BenchmarkSpinLock-10 58953211 18.01 ns/op 0 B/op 0 allocs/op
BenchmarkBackOffSpinLock-10 100000000 10.81 ns/op 0 B/op 0 allocs/op
*/
type originSpinLock uint32

View File

@ -28,7 +28,7 @@ import (
"sync/atomic"
"time"
"github.com/panjf2000/ants/v2/internal"
syncx "github.com/panjf2000/ants/v2/internal/sync"
)
// Pool accepts the tasks from client, it limits the total of goroutines to a given number by recycling goroutines.
@ -180,7 +180,7 @@ func NewPool(size int, options ...Option) (*Pool, error) {
p := &Pool{
capacity: int32(size),
lock: internal.NewSpinLock(),
lock: syncx.NewSpinLock(),
options: opts,
}
p.workerCache.New = func() interface{} {

View File

@ -28,7 +28,7 @@ import (
"sync/atomic"
"time"
"github.com/panjf2000/ants/v2/internal"
syncx "github.com/panjf2000/ants/v2/internal/sync"
)
// PoolWithFunc accepts the tasks from client,
@ -208,7 +208,7 @@ func NewPoolWithFunc(size int, pf func(interface{}), options ...Option) (*PoolWi
p := &PoolWithFunc{
capacity: int32(size),
poolFunc: pf,
lock: internal.NewSpinLock(),
lock: syncx.NewSpinLock(),
options: opts,
}
p.workerCache.New = func() interface{} {