All Projects → yale8848 → Gorpool

yale8848 / Gorpool

Licence: mit
Simple Goroutine pool

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gorpool

Grpool
Lightweight Goroutine pool
Stars: ✭ 616 (+1564.86%)
Mutual labels:  pool, goroutine
errgroup
errgroup with goroutine worker limits
Stars: ✭ 143 (+286.49%)
Mutual labels:  pool, goroutine
Ants
🐜🐜🐜 ants is a high-performance and low-cost goroutine pool in Go, inspired by fasthttp./ ants 是一个高性能且低损耗的 goroutine 池。
Stars: ✭ 7,180 (+19305.41%)
Mutual labels:  pool, goroutine
goroutine-pool
A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.
Stars: ✭ 31 (-16.22%)
Mutual labels:  pool, goroutine
workerpool
A workerpool that can get expanded & shrink dynamically.
Stars: ✭ 55 (+48.65%)
Mutual labels:  pool, goroutine
gohive
🐝 A Highly Performant and easy to use goroutine pool for Go
Stars: ✭ 41 (+10.81%)
Mutual labels:  pool, goroutine
Golang runtime reading
golang 1.10.2 runtime code reading - golang runtime源码分析。只有思考过,你才会印象深刻。
Stars: ✭ 393 (+962.16%)
Mutual labels:  goroutine
Pgagroal
High-performance connection pool for PostgreSQL
Stars: ✭ 362 (+878.38%)
Mutual labels:  pool
Machine
Machine is a zero dependency library for highly concurrent Go applications. It is inspired by errgroup.Group with extra bells & whistles
Stars: ✭ 346 (+835.14%)
Mutual labels:  goroutine
Reading
整理阅读过的干货文章, 帖子
Stars: ✭ 318 (+759.46%)
Mutual labels:  goroutine
Leaktest
Goroutine Leak Detector
Stars: ✭ 872 (+2256.76%)
Mutual labels:  goroutine
Oeasypool
c++11 thread pool
Stars: ✭ 18 (-51.35%)
Mutual labels:  pool
Btcpool Abandoned
backend of pool.btc.com
Stars: ✭ 541 (+1362.16%)
Mutual labels:  pool
Libcopp
cross-platform coroutine library in c++
Stars: ✭ 398 (+975.68%)
Mutual labels:  pool
Go spider
A golang spider
Stars: ✭ 25 (-32.43%)
Mutual labels:  goroutine
Mojito
An easy-to-use Elixir HTTP client, built on the low-level Mint library.
Stars: ✭ 333 (+800%)
Mutual labels:  pool
Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+1337.84%)
Mutual labels:  goroutine
Honeydew
Job Queue for Elixir. Clustered or Local. Straight BEAM. Optional Ecto. 💪🍈
Stars: ✭ 670 (+1710.81%)
Mutual labels:  pool
Blog
Jiajun的编程随想
Stars: ✭ 528 (+1327.03%)
Mutual labels:  goroutine
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (+1178.38%)
Mutual labels:  pool

gorpool

Simple Goroutine pool

How to use

go get github.com/yale8848/[email protected]

Simple example


package main

import (
	"github.com/yale8848/gorpool"
	"time"
	"fmt"
)

func main() {

    // workerNum is worker number of goroutine pool ,one worker have one goroutine ,
    // jobNum is job number of job pool
	p := gorpool.NewPool(5, 10).
		Start()
	defer p.StopAll()
	for i := 0; i < 100; i++ {
		count := i
		p.AddJob(func() {
			time.Sleep(10 * time.Millisecond)
			fmt.Printf("%d\r\n", count)
		})

	}
	time.Sleep(2 * time.Second)
}

WaitForAll


package main

import (
	"fmt"
	"github.com/yale8848/gorpool"
	"time"
)

func main() {

	p := gorpool.NewPool(5, 10).
		Start().
		EnableWaitForAll(true)
	for i := 0; i < 100; i++ {
		count := i
		p.AddJob(func() {
			time.Sleep(10 * time.Millisecond)
			fmt.Printf("%d\r\n", count)
		})
	}
	p.WaitForAll()
	p.StopAll()
}

SetIdleDuration

After set idle duration , the worker will stop it worker go routine


package main

import (
	"fmt"
	"github.com/yale8848/gorpool"
	"time"
)

func main() {

	p := gorpool.NewPool(5, 10).
		SetIdleDuration(3 * time.Second).
		Start().
		EnableWaitForAll(true)
	for i := 0; i < 100; i++ {
		count := i
		p.AddJob(func() {
			time.Sleep(5 * time.Second)
			fmt.Printf("%d\r\n", count)
		})
	}
	p.WaitForAll()
	p.StopAll()
}

Doc

gorpool doc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].