diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 78f55b96..cfea99b3 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -44,7 +44,7 @@ autolabeler: title: - /fix/i - /bug/i - - /patch/i + - /resolve/i - label: docs files: - '*.md' @@ -60,6 +60,15 @@ autolabeler: - /update/i - /remove/i - /delete/i + - label: optimization + title: + - /opt:/i + - /refactor/i + - /optimize/i + - /improve/i + - /update/i + - /remove/i + - /delete/i - label: new feature title: - /feat:/i @@ -75,7 +84,7 @@ autolabeler: - label: chores title: - /chore/i - - /\bmisc\b/i + - /misc/i - /cleanup/i - /clean up/i - label: major diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c860ccd..adf95dc2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,7 +101,7 @@ jobs: run: go test -v -race -coverprofile="codecov.report" -covermode=atomic - name: Upload code coverage report to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: file: ./codecov.report flags: unittests diff --git a/README.md b/README.md index 40f1ca8e..78c77e43 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@
+ diff --git a/README_ZH.md b/README_ZH.md index 20e03ffc..e422f74c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -7,6 +7,7 @@
+ diff --git a/ants.go b/ants.go index 4b61ba2b..01af0c61 100644 --- a/ants.go +++ b/ants.go @@ -20,6 +20,13 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +// Package ants implements an efficient and reliable goroutine pool for Go. +// +// With ants, Go applications are able to limit the number of active goroutines, +// recycle goroutines efficiently, and reduce the memory footprint significantly. +// Package ants is extremely useful in the scenarios where a massive number of +// goroutines are created and destroyed frequently, such as highly-concurrent +// batch processing systems, HTTP servers, services of asynchronous tasks, etc. package ants import ( diff --git a/pool.go b/pool.go index 2106e83f..ad407a5b 100644 --- a/pool.go +++ b/pool.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - syncx "github.com/panjf2000/ants/v2/internal/sync" + syncx "github.com/panjf2000/ants/v2/sync" ) type poolCommon struct { diff --git a/pool_func.go b/pool_func.go index 29541064..b1322e69 100644 --- a/pool_func.go +++ b/pool_func.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - syncx "github.com/panjf2000/ants/v2/internal/sync" + syncx "github.com/panjf2000/ants/v2/sync" ) // PoolWithFunc accepts the tasks and process them concurrently, diff --git a/internal/sync/spinlock.go b/sync/spinlock.go similarity index 100% rename from internal/sync/spinlock.go rename to sync/spinlock.go diff --git a/internal/sync/spinlock_test.go b/sync/spinlock_test.go similarity index 96% rename from internal/sync/spinlock_test.go rename to sync/spinlock_test.go index fa20401c..6c5a5240 100644 --- a/internal/sync/spinlock_test.go +++ b/sync/spinlock_test.go @@ -15,7 +15,7 @@ import ( Benchmark result for three types of locks: goos: darwin goarch: arm64 - pkg: github.com/panjf2000/ants/v2/internal/sync + pkg: github.com/panjf2000/ants/v2/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 diff --git a/sync/sync.go b/sync/sync.go new file mode 100644 index 00000000..d66192f0 --- /dev/null +++ b/sync/sync.go @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025. Andy Pan. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// Package sync provides some handy implementations for synchronization access. +// At the moment, there is only an implementation of spin-lock. +package sync