Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/peakle/bees

Memory lightweight goroutines pool
https://github.com/peakle/bees

go golang goroutine-pool pool

Last synced: 7 days ago
JSON representation

Memory lightweight goroutines pool

Awesome Lists containing this project

README

        

# Bees

[![Tests](https://github.com/peakle/bees/workflows/Tests/badge.svg)](https://github.com/peakle/bees/blob/master/.github/workflows/ci.yml)
[![codecov](https://codecov.io/gh/peakle/bees/branch/master/graph/badge.svg)](https://codecov.io/gh/peakle/bees)
[![Go Report Card](https://goreportcard.com/badge/github.com/peakle/bees)](https://goreportcard.com/report/github.com/peakle/bees)
[![Go Reference](https://pkg.go.dev/badge/github.com/peakle/bees.svg)](https://pkg.go.dev/github.com/peakle/bees)

Bees - simple and lightweight worker pool for go.

## Benchmarks:

### [10m tasks and 500k workers](https://github.com/peakle/bees/blob/master/pool_bench_test.go):

#### WorkerPool:

WorkerPoolBench

only 37MB used for 500k workers pool

#### Goroutines:

GoroutinesBench

#### Semaphore:

SemaphoreBench

## Examples:

```go
package main

import (
"context"
"fmt"

"github.com/peakle/bees"
)

// Example - demonstrate pool usage
func Example() {
pool := bees.Create(context.Background())
defer pool.Close()

t := 1
task := func(ctx context.Context) {
t++
fmt.Println(t)
}
pool.Submit(task)
pool.Submit(task)
pool.Submit(task)

pool.Wait()
// Output:
// 1
// 2
// 3
}

```