From: qydysky Date: Sat, 23 Mar 2024 10:08:30 +0000 (+0800) Subject: 1 X-Git-Tag: v0.28.20240323102607~1 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=6b3f6c0e1ea6fd4de3369c140b107c7e592460d7;p=part%2F.git 1 --- diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f471718..9fffbb6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,6 +75,7 @@ jobs: go test -count 1 -timeout 5s -v -race github.com/qydysky/part/component go test -count 1 -timeout 15s -v -race github.com/qydysky/part/ctx go test -count 1 -timeout 5s -v -race github.com/qydysky/part/slice + go test -count 1 -timeout 5s -v -race github.com/qydysky/part/bools u-test: name: u-test @@ -109,6 +110,7 @@ jobs: go test -count 1 -timeout 5s -v -race github.com/qydysky/part/component go test -count 1 -timeout 15s -v -race github.com/qydysky/part/ctx go test -count 1 -timeout 5s -v -race github.com/qydysky/part/slice + go test -count 1 -timeout 5s -v -race github.com/qydysky/part/bools test: name: test @@ -121,6 +123,6 @@ jobs: echo "HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV - name: Upload a Release Asset - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: tag_name: v0.28.${{ env.TIME }} \ No newline at end of file diff --git a/funcCtrl/FuncCtrl.go b/funcCtrl/FuncCtrl.go index ae9e413..ab5cfc2 100644 --- a/funcCtrl/FuncCtrl.go +++ b/funcCtrl/FuncCtrl.go @@ -111,6 +111,11 @@ func (t *BlockFuncN) UnBlock(failF ...func()) { t.n.Add(-1) } +func (t *BlockFuncN) BlockF(failF ...func()) (unBlock func(failF ...func())) { + t.Block(failF...) + return t.UnBlock +} + func (t *BlockFuncN) BlockAll(failF ...func()) { for !t.n.CompareAndSwap(0, -1) { for i := 0; i < len(failF); i++ { @@ -120,8 +125,16 @@ func (t *BlockFuncN) BlockAll(failF ...func()) { } } -func (t *BlockFuncN) UnBlockAll() { - if !t.n.CompareAndSwap(-1, 0) { - panic("must BlockAll First") +func (t *BlockFuncN) UnBlockAll(failF ...func()) { + for !t.n.CompareAndSwap(-1, 0) { + for i := 0; i < len(failF); i++ { + failF[i]() + } + runtime.Gosched() } } + +func (t *BlockFuncN) BlockAllF(failF ...func()) (unBlock func(failF ...func())) { + t.BlockAll(failF...) + return t.UnBlockAll +} diff --git a/funcCtrl/FuncCtrl_test.go b/funcCtrl/FuncCtrl_test.go index 0ef03c7..e8b220a 100644 --- a/funcCtrl/FuncCtrl_test.go +++ b/funcCtrl/FuncCtrl_test.go @@ -132,7 +132,7 @@ func Test_BlockFuncN(t *testing.T) { cc += <-c } if cc != "010212" { - t.Fatal() + t.Fatal(cc) } // t.Log(cc) }