Skip to content

brickingsoft/rxp

Repository files navigation

rxp

快速执行池,一个 Go 的协程池。

安装

go get -u github.com/brickingsoft/rxp

使用

type Task struct {
}

func (task *Task) Handle(ctx context.Context) {
	// do something
}
service, err := rxp.New()
ctx := context.TODO()
service.TryExecute(ctx, &Task{})
err := service.Close()

压测(并行)

// goos: windows
// goarch: amd64
// cpu: 13th Gen Intel(R) Core(TM) i5-13600K
项目 数量 ns/op B/op allocs/op failed
Parallel 2803556 422.6 0 0 0
项目 数量 ns/op B/op allocs/op
rxp 2803556 422.6 0 0
github.com/panjf2000/ants/v2 2547340 468.8 0 0
github.com/alitto/pond/v2 2619438 876.9 224 7
github.com/alitto/pond 2025330 558.5 224 7