]> 127.0.0.1 Git - part/.git/commitdiff
PlanDone v0.20.1
authorqydysky <32743305+qydysky@users.noreply.github.com>
Tue, 10 Jan 2023 13:31:27 +0000 (21:31 +0800)
committerqydysky <32743305+qydysky@users.noreply.github.com>
Tue, 10 Jan 2023 13:31:27 +0000 (21:31 +0800)
funcCtrl/FuncCtrl.go
funcCtrl/FuncCtrl_test.go

index 054c1581d15a4466a4eacbe71a892ef92ba51d49..9ba7211b7b24a41f5e074a3330130ca886ddac3c 100644 (file)
@@ -111,8 +111,11 @@ func (t *BlockFuncN) Plan(n int64) {
        }
 }
 
-func (t *BlockFuncN) PlanDone() {
+func (t *BlockFuncN) PlanDone(switchFuncs ...func()) {
        for atomic.LoadInt64(&t.plan) > 0 {
+               for i := 0; i < len(switchFuncs); i++ {
+                       switchFuncs[i]()
+               }
                runtime.Gosched()
        }
 }
index e640372035bd71c66d3e135e740d311aae49563d..365d90be61bb92ada2cac1c5e4937883378da1ef 100644 (file)
@@ -94,6 +94,8 @@ func Test_BlockFuncNPlan(t *testing.T) {
        go a(1)
        go a(2)
        go a(3)
-       b.PlanDone()
+       b.PlanDone(func() {
+               time.Sleep(time.Microsecond * 10)
+       })
        t.Log(`fin`)
 }