pool

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

package pool

A pool allows a particular type of work to run in it and limits its parallel number and maximum wait queue length.

Usage:

import "github.com/infavor/gox/pool"

// init a task pool which allow 2 tasks run in parallel,
// and max wait task count is 100.
p := pool.New(1, 100)
for i := 0; i < 100; i++ {
    tmp := i
    err := p.Push(func() {
        myfunc(...){}
    })
    if err != nil {
        fmt.Println("Err:", err)
    }
}

Documentation

Overview

Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.

A pool allows a particular type of work to run in it and limits its parallel number and maximum wait queue length. license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkPool

type WorkPool interface {
	Push(task func()) error
}

func New

func New(coreSize int, maxWait int) WorkPool

New creates a task pool.

Jump to

Keyboard shortcuts

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