gf: github.com/gogf/gf/g/os/grpool Index | Files

package grpool

import "github.com/gogf/gf/g/os/grpool"

Package grpool implements a goroutine reusable pool.

Index

Package Files

grpool.go

func Add Uses

func Add(f func()) error

Add pushes a new job to the pool using default goroutine pool. The job will be executed asynchronously.

func Jobs Uses

func Jobs() int

Jobs returns current job count of default goroutine pool.

func Size Uses

func Size() int

Size returns current goroutine count of default goroutine pool.

type Pool Uses

type Pool struct {
    // contains filtered or unexported fields
}

Goroutine Pool

func New Uses

func New(limit ...int) *Pool

New creates and returns a new goroutine pool object. The parameter <limit> is used to limit the max goroutine count, which is not limited in default.

func (*Pool) Add Uses

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

Add pushes a new job to the pool. The job will be executed asynchronously.

func (*Pool) Cap Uses

func (p *Pool) Cap() int

Cap returns the capacity of the pool. This capacity is defined when pool is created. If it returns -1 means no limit.

func (*Pool) Close Uses

func (p *Pool) Close()

Close closes the goroutine pool, which makes all goroutines exit.

func (*Pool) IsClosed Uses

func (p *Pool) IsClosed() bool

IsClosed returns if pool is closed.

func (*Pool) Jobs Uses

func (p *Pool) Jobs() int

Jobs returns current job count of the pool.

func (*Pool) Size Uses

func (p *Pool) Size() int

Size returns current goroutine count of the pool.

Package grpool imports 3 packages (graph) and is imported by 2 packages. Updated 2019-06-26. Refresh now. Tools for package owners.