Skip to content
/ gp Public

A nano goroutine pool implementation in several lines

License

Notifications You must be signed in to change notification settings

tiancaiamao/gp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple goroutine pool

Rational

Goroutine is cheap, but not free. Especially when the goroutine trigger runtime.morestack, the cost become high.

This package is mainly aimed to handle that. Put back the stack-growed goroutine to a pool, and reuse that goroutine can eliminate the runtime.morestack cost.

See a blog post (Chinese) https://www.zenlife.tk/goroutine-pool.md

Usage

Just replace your go f() call with gp.Go(f):

import "github.com/tiancaiamao/gp"

var gP = gp.New(N, time.Duration)

gp.Go(func() {
	// ...
})

About

A nano goroutine pool implementation in several lines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages