gxruntime

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: Apache-2.0 Imports: 7 Imported by: 4

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.

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
2017-11-05 16:38 Package gxpprof provides go process info
2017-11-05 16:38 Package gxpprof provides go process info

Jump to

Keyboard shortcuts

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