Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Yiming1997/go-agile-pool

Repository files navigation

Introduction

goAgilePool is a lightweight goroutine pool for Golang, designed for simplicity and high performance

Features

  1. Customizable goroutine pool size
  2. Configurable task queue size
  3. Task timeout control
  4. Automatic cleanup of idle workers upon timeout
  5. Efficient worker reuse through FIFO worker queue management

Installation

go get github.com/Yiming1997/go-agile-pool

Usage

Pool.Submit()

	pool := agilepool.NewPool()

	pool.InitConfig().
		WithCleanPeriod(500 * time.Millisecond).
		WithTaskQueueSize(10000).
		WithWorkerNumCapacity(20000)

	pool.Init()

	for i := 0; i < 20000000; i++ {
		go func() {
			pool.Submit(agilepool.TaskFunc(func() {
				time.Sleep(10 * time.Millisecond)

			}))

		}()
	}

	pool.Wait() 

Pool.SubmitBefore()

	pool.SubmitBefore(func() {
		time.Sleep(10 * time.Millisecond)
	}, 5*time.Second)

benchmark

BenchmarkAgilePool-14    	       1	5881506800 ns/op	230601408 B/op	10871762 allocs/op

About

A golang goroutine pool with high-performance and elegance

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages