All Projects → hnlq715 → goroutine-pool

hnlq715 / goroutine-pool

Licence: MIT license
A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to goroutine-pool

gohive
🐝 A Highly Performant and easy to use goroutine pool for Go
Stars: ✭ 41 (+32.26%)
Mutual labels:  pool, goroutine, goroutine-pool
Ants
🐜🐜🐜 ants is a high-performance and low-cost goroutine pool in Go, inspired by fasthttp./ ants 是一个高性能且低损耗的 goroutine 池。
Stars: ✭ 7,180 (+23061.29%)
Mutual labels:  pool, goroutine, goroutine-pool
errgroup
errgroup with goroutine worker limits
Stars: ✭ 143 (+361.29%)
Mutual labels:  pool, goroutine, goroutine-pool
Grpool
Lightweight Goroutine pool
Stars: ✭ 616 (+1887.1%)
Mutual labels:  pool, goroutine
Gorpool
Simple Goroutine pool
Stars: ✭ 37 (+19.35%)
Mutual labels:  pool, goroutine
workerpool
A workerpool that can get expanded & shrink dynamically.
Stars: ✭ 55 (+77.42%)
Mutual labels:  pool, goroutine
goroutines
It is an efficient, flexible, and lightweight goroutine pool. It provides an easy way to deal with concurrent tasks with limited resource.
Stars: ✭ 88 (+183.87%)
Mutual labels:  pool, goroutine-pool
ecs
Build your own Game-Engine based on the Entity Component System concept in Golang.
Stars: ✭ 68 (+119.35%)
Mutual labels:  goroutine
go-workshops
Go language basic workshops for devz
Stars: ✭ 68 (+119.35%)
Mutual labels:  goroutine
42-piscine-exam
This repo has all exercises of "C Exam Alone In The Dark - Beginner" sorted from level_00 to Level_05
Stars: ✭ 218 (+603.23%)
Mutual labels:  pool
safeminer
全网第一款本地连接矿池加密软件,隐藏本地ip、加密数据包、流量混淆,可实现防止被监管的目的
Stars: ✭ 8 (-74.19%)
Mutual labels:  pool
workerPool
Auto scaling goroutine pool.
Stars: ✭ 18 (-41.94%)
Mutual labels:  goroutine-pool
parallelizer
Simplifies the parallelization of function calls.
Stars: ✭ 62 (+100%)
Mutual labels:  pool
noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (+177.42%)
Mutual labels:  goroutine
chanbroker
ChanBroker, a Broker for goroutine, is simliar to kafka
Stars: ✭ 61 (+96.77%)
Mutual labels:  goroutine
context
A proof of concept implementation of scoped context
Stars: ✭ 16 (-48.39%)
Mutual labels:  goroutine
billiards
billiards physics
Stars: ✭ 37 (+19.35%)
Mutual labels:  pool
fastglue
Fastglue is an opinionated, bare bones wrapper that glues together fasthttp and fasthttprouter to act as a micro HTTP framework.
Stars: ✭ 71 (+129.03%)
Mutual labels:  fasthttp
open-grin-pool
Open-sourcing pool for grin. Easy to depoly and keep KISS in design. Avaliable to epic (epicash, a grin forkcoin) too.
Stars: ✭ 19 (-38.71%)
Mutual labels:  pool
pool-reference
Reference python implementation of Chia pool operations for pool operators
Stars: ✭ 452 (+1358.06%)
Mutual labels:  pool

goroutine-pool

Build Status Coverage

A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.

install

go get -u -v github.com/hnlq715/goroutine-pool

example

package main

import (
	"fmt"
	pool "github.com/hnlq715/goroutine-pool"
	"sync"
)

func main() {
	pool.Start()
	defer pool.Stop()

	wg := sync.WaitGroup{}
	for i := 0; i < 5; i++ {
		wg.Add(1)
		pool.Go(func() {
			fmt.Println(i)
			wg.Done()
		})
	}
	wg.Wait()
	fmt.Println()

	for i := 0; i < 5; i++ {
		wg.Add(1)
		n := i
		pool.Go(func() {
			fmt.Println(n)
			wg.Done()
		})
	}
	wg.Wait()
}
$ go run main.go
5
5
5
5
5

4
1
0
2
3

benchmarks

With Wait

Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkGoroutine$

goos: windows
goarch: amd64
pkg: workerpool
BenchmarkGoroutine-4   	    1000	   1634621 ns/op	      65 B/op	       1 allocs/op
PASS
ok  	workerpool	2.047s
Success: Benchmarks passed.
Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkPool$

goos: windows
goarch: amd64
pkg: workerpool
BenchmarkPool-4   	    2000	   1146818 ns/op	      17 B/op	       1 allocs/op
PASS
ok  	workerpool	2.702s
Success: Benchmarks passed.

Without Wait

cpu run at 100%

Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkGoroutineWithoutWait$

goos: windows
goarch: amd64
pkg: workerpool
BenchmarkGoroutineWithoutWait-4   	 1000000	      4556 ns/op	     517 B/op	       1 allocs/op
PASS
ok  	workerpool	5.649s
Success: Benchmarks passed.

cpu relatively low

Running tool: D:\Go\bin\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkPoolWithoutWait$

goos: windows
goarch: amd64
pkg: workerpool
BenchmarkPoolWithoutWait-4   	10000000	       144 ns/op	       3 B/op	       0 allocs/op
PASS
ok  	workerpool	4.812s
Success: Benchmarks passed.
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].