Skip to content

Xiaoxusheng/pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go协程池简单实现

1 因为自已需要一直写一个协程池来控制goroutine数量与并发情况

2 目前正在写一个go协程池的简单实现,目前只实现了简单的功能,后续会继续完善

3 用法

go get github.com/Xiaoxusheng/pool
package main

import (
	"context"
	"log"
	"github.com/Xiaoxusheng/pool/queue"
)

func main() {

	pool := queue.NewPool(20, 10)
	ctx := context.Background()

	for i := 0; i < 300; i++ {
		i = i
		err := pool.Submit(ctx, func(v ...interface{}) {
			log.Println(i)
		})
		if err != nil {
			log.Println(err)
			return
		}
	}
	pool.Wait()
}

About

go协程池的简单实现

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages