Help us shape the future of Go! Take the 2026 Go Developer Survey

gxruntime

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Overview

2017-10-24 16:20 Package gxruntime encapsulates some runtime functions goroutine pool ref: https://github.com/pingcap/tidb/blob/1592c7bc2873346565ab15ecfbc22749a775e014/util/goroutine_pool/gp.go

Index

Constants

View Source
const (
	PoolInit = iota
	PoolStarting
	PoolGcing
	PoolClosing
	PoolClosed
)
View Source
const (
	OnceLoopGoroutineNum = 30
)

Variables

View Source
var (
	ErrGoroutinePoolClosed = fmt.Errorf("GoroutinePool has been closed.")
)

Functions

func GoID

func GoID() int

Types

type Pool added in v0.2.0

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Pool is a struct to represent goroutine pool.

func NewGoroutinePool added in v0.2.0

func NewGoroutinePool(idleTimeout time.Duration) *Pool

New returns a new *Pool object. DEPRECATED: https://github.com/pingcap/tidb/pull/7564 After Go1.11, goroutine pool is harmful.

The test result is as follows: go test -test.bench Benchmark goos: darwin goarch: amd64 pkg: github.com/AlexStocks/goext/runtime BenchmarkGoPool-4 3000000 619 ns/op BenchmarkGo-4 5000000 319 ns/op BenchmarkMorestackPool-4 3000000 534 ns/op BenchmarkMoreStack-4 2000000 667 ns/op

func (*Pool) Close added in v0.2.0

func (p *Pool) Close()

func (*Pool) Go added in v0.2.0

func (p *Pool) Go(f func()) error

Go works like go func(), but goroutines are pooled for reusing. This strategy can avoid runtime.morestack, because pooled goroutine is already enlarged.

func (*Pool) IsClosed added in v0.2.0

func (p *Pool) IsClosed() bool

check whether the pool has been closed.

Directories

Path Synopsis
Package autopprof provides a development-time library to collect pprof profiles from Go programs.
Package autopprof provides a development-time library to collect pprof profiles from Go programs.

Jump to

Keyboard shortcuts

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