Skip to content

Repository files navigation

Obvious workpool implementation

Contributor Covenant License GitHub release

No frills workerpool implementation.

How to Use

Installation

go get github.com/go-obvious/workerpool

Example Usage

package main

import (
    "fmt"
    "github.com/go-obvious/workerpool"
)

func main() {
    pool := workerpool.New(10, 10)
    pool.Start()
    defer pool.Stop()

    var wg sync.WaitGroup
    values := make([]int, itemCount+1)
    for i := 0; i < itemCount; i++ {
        i := i
        pipevalue := func() {
            defer wg.Done()
            values[i] = i
        }
        wg.Add(1)
        inst.WorkCh <- pipevalue
    }
    wg.Wait()

    // workers are done, print the values
    for entry := range values {
        fmt.Printf("%d\n", entry)
    }
}

About

Simple workerpool implementation

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages