Skip to content

Commit

Permalink
Merge pull request #286 from panjf2000/dev
Browse files Browse the repository at this point in the history
ver: release v2.8.0
  • Loading branch information
panjf2000 committed Jul 1, 2023
2 parents 78ff6e0 + 45a0390 commit 1411ae8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,18 @@ on:
- dev
paths-ignore:
- '**.md'
- '.github/FUNDING.yml'
- '.github/release-drafter.yml'
- '.github/ISSUE_TEMPLATE/*'
- '.github/workflows/pull-request.yml'
- '.github/workflows/release-drafter.yml'
- '**.yml'
- '**.yaml'
- '!.github/workflows/codeql.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '**.md'
- '.github/FUNDING.yml'
- '.github/release-drafter.yml'
- '.github/ISSUE_TEMPLATE/*'
- '.github/workflows/pull-request.yml'
- '.github/workflows/release-drafter.yml'
- '**.yml'
- '**.yaml'
- '!.github/workflows/codeql.yml'
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@ on:
- dev
paths-ignore:
- '**.md'
- '.github/FUNDING.yml'
- '.github/release-drafter.yml'
- '.github/ISSUE_TEMPLATE/*'
- '.github/workflows/codeql.yml'
- '.github/workflows/pull-request.yml'
- '.github/workflows/release-drafter.yml'
- '**.yml'
- '**.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '**.md'
- '.github/FUNDING.yml'
- '.github/release-drafter.yml'
- '.github/ISSUE_TEMPLATE/*'
- '.github/workflows/codeql.yml'
- '.github/workflows/pull-request.yml'
- '.github/workflows/release-drafter.yml'
- '**.yml'
- '**.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'

env:
GO111MODULE: on
Expand Down
5 changes: 5 additions & 0 deletions ants.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ func 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.
func Reboot() {
defaultAntsPool.Reboot()
Expand Down
12 changes: 12 additions & 0 deletions ants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,15 @@ func TestReleaseTimeout(t *testing.T) {
err = pf.ReleaseTimeout(2 * time.Second)
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)
}

0 comments on commit 1411ae8

Please sign in to comment.