mirror of
https://github.com/panjf2000/ants.git
synced 2025-12-16 18:11:03 +00:00
commit
1411ae852f
16
.github/workflows/codeql.yml
vendored
16
.github/workflows/codeql.yml
vendored
@ -7,22 +7,18 @@ on:
|
|||||||
- dev
|
- dev
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/FUNDING.yml'
|
- '**.yml'
|
||||||
- '.github/release-drafter.yml'
|
- '**.yaml'
|
||||||
- '.github/ISSUE_TEMPLATE/*'
|
- '!.github/workflows/codeql.yml'
|
||||||
- '.github/workflows/pull-request.yml'
|
|
||||||
- '.github/workflows/release-drafter.yml'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- dev
|
- dev
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/FUNDING.yml'
|
- '**.yml'
|
||||||
- '.github/release-drafter.yml'
|
- '**.yaml'
|
||||||
- '.github/ISSUE_TEMPLATE/*'
|
- '!.github/workflows/codeql.yml'
|
||||||
- '.github/workflows/pull-request.yml'
|
|
||||||
- '.github/workflows/release-drafter.yml'
|
|
||||||
schedule:
|
schedule:
|
||||||
# ┌───────────── minute (0 - 59)
|
# ┌───────────── minute (0 - 59)
|
||||||
# │ ┌───────────── hour (0 - 23)
|
# │ ┌───────────── hour (0 - 23)
|
||||||
|
|||||||
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
@ -7,26 +7,20 @@ on:
|
|||||||
- dev
|
- dev
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/FUNDING.yml'
|
- '**.yml'
|
||||||
- '.github/release-drafter.yml'
|
- '**.yaml'
|
||||||
- '.github/ISSUE_TEMPLATE/*'
|
|
||||||
- '.github/workflows/codeql.yml'
|
|
||||||
- '.github/workflows/pull-request.yml'
|
|
||||||
- '.github/workflows/release-drafter.yml'
|
|
||||||
- 'examples/*'
|
- 'examples/*'
|
||||||
|
- '!.github/workflows/test.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- dev
|
- dev
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- '.github/FUNDING.yml'
|
- '**.yml'
|
||||||
- '.github/release-drafter.yml'
|
- '**.yaml'
|
||||||
- '.github/ISSUE_TEMPLATE/*'
|
|
||||||
- '.github/workflows/codeql.yml'
|
|
||||||
- '.github/workflows/pull-request.yml'
|
|
||||||
- '.github/workflows/release-drafter.yml'
|
|
||||||
- 'examples/*'
|
- 'examples/*'
|
||||||
|
- '!.github/workflows/test.yml'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
|
|||||||
5
ants.go
5
ants.go
@ -123,6 +123,11 @@ func Release() {
|
|||||||
defaultAntsPool.Release()
|
defaultAntsPool.Release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReleaseTimeout is like Release but with a timeout, it waits all workers to exit before timing out.
|
||||||
|
func ReleaseTimeout(timeout time.Duration) error {
|
||||||
|
return defaultAntsPool.ReleaseTimeout(timeout)
|
||||||
|
}
|
||||||
|
|
||||||
// Reboot reboots the default pool.
|
// Reboot reboots the default pool.
|
||||||
func Reboot() {
|
func Reboot() {
|
||||||
defaultAntsPool.Reboot()
|
defaultAntsPool.Reboot()
|
||||||
|
|||||||
12
ants_test.go
12
ants_test.go
@ -973,3 +973,15 @@ func TestReleaseTimeout(t *testing.T) {
|
|||||||
err = pf.ReleaseTimeout(2 * time.Second)
|
err = pf.ReleaseTimeout(2 * time.Second)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDefaultPoolReleaseTimeout(t *testing.T) {
|
||||||
|
Reboot()
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
_ = Submit(func() {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
assert.NotZero(t, Running())
|
||||||
|
err := ReleaseTimeout(2 * time.Second)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user