salmon

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 3

README

Salmon

[ants]

golang 协程池, 对 `github.com/panjf2000/ants/v2` 的二次封装

修改部分

  • 代码内封装了 sync.WaitGroup.Add() 和 sync.WaitGroup.Done() 、sync.WaitGroup.Wait() 函数的自动调用,

    外部调用只需要关注业务逻辑

  • 添加 cancel 函数,调用后,阻塞中的任务将不执行

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	// Invoke 往池内提交任务
	Invoke(fn WorkFunc) error
	// Stop 手动停止任务
	Stop()
	// Wait 等待所有任务完成
	Wait()
}

Pool .

func NewPool

func NewPool(size int) (Pool, error)

NewPool .

type WorkFunc added in v1.0.2

type WorkFunc func(cancel func())

WorkFunc . 调用 cancel 后,阻塞中的任务将不执行

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL