Skip to content
forked from dean2021/hackpool

优雅的go协程库,轻松控制并发数

Notifications You must be signed in to change notification settings

idersec/hackpool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HackPool

北半球最优雅的协程池

Example

package main

import (
	"fmt"
	"github.com/poc-db/hackpool"
)

func main() {

	concurrency := 2   // 并发数
	taskCount := 100   

	hp := hackpool.New(concurrency, func(i interface{}) {
		fmt.Println(i.(int))
	})

	go func() {

		for i := 0; i < taskCount; i++ {
			hp.Push(i)
		}

		// 必须关闭,不然阻塞死锁
		hp.Close()
	}()

	// 跑起来! 伙计
	hp.Run()
}

Installation

go get github.com/poc-db/hackpool

License

This project is copyleft of CSOIO and released under the GPL 3 license.

About

优雅的go协程库,轻松控制并发数

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%