Skip to content

Commit

Permalink
feat: super 包新增 WaitGroup 结构,用法同 sync.WaitGroup,包含一个额外的 Exec 函数,用于便捷的…
Browse files Browse the repository at this point in the history
…执行异步函数。移除 stack.go 相关的无用代码
  • Loading branch information
kercylan98 committed Mar 12, 2024
1 parent 1402b85 commit c98d15b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 53 deletions.
53 changes: 0 additions & 53 deletions utils/super/stack.go

This file was deleted.

24 changes: 24 additions & 0 deletions utils/super/wg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package super

import (
"github.com/kercylan98/minotaur/utils/log"
"sync"
)

type WaitGroup struct {
sync.WaitGroup
}

func (w *WaitGroup) Exec(f func()) {
w.WaitGroup.Add(1)
go func(w *WaitGroup) {
defer func() {
w.WaitGroup.Done()
if err := RecoverTransform(recover()); err != nil {
log.Error("WaitGroup", log.Err(err))
}
}()

f()
}(w)
}

0 comments on commit c98d15b

Please sign in to comment.