包含Go API项目的所有源代码、配置文件、Docker配置、文档和前端资源 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
25 lines
539 B
Go
25 lines
539 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/bytedance/gopkg/util/gopool"
|
|
"math"
|
|
)
|
|
|
|
var relayGoPool gopool.Pool
|
|
|
|
func init() {
|
|
relayGoPool = gopool.NewPool("gopool.RelayPool", math.MaxInt32, gopool.NewConfig())
|
|
relayGoPool.SetPanicHandler(func(ctx context.Context, i interface{}) {
|
|
if stopChan, ok := ctx.Value("stop_chan").(chan bool); ok {
|
|
SafeSendBool(stopChan, true)
|
|
}
|
|
SysError(fmt.Sprintf("panic in gopool.RelayPool: %v", i))
|
|
})
|
|
}
|
|
|
|
func RelayCtxGo(ctx context.Context, f func()) {
|
|
relayGoPool.CtxGo(ctx, f)
|
|
}
|