Skip to content

ndrewnee/pool

Repository files navigation

pool

GoDoc Go Report Card Build Status Coverage Status Contributions Welcome

Description

Simple pool of workers

Installation

go get github.com/ndrewnee/pool

Usage

package main

import (
    "errors"
    "log"

    "github.com/ndrewnee/pool"
)

func main() {
    jobs := []*pool.Job{
        pool.NewJob(func() error { return nil }),
        pool.NewJob(func() error { return errors.New("some error") }),
    }

    p := pool.NewPool(jobs, 10)
    p.Run()

    for i, job := range p.Jobs() {
        if err := job.Err(); err != nil {
            log.Printf("Job with index %v failed: %v\n", i, err)
            continue
        }

        log.Printf("Job with index %v finished successfully\n", i)
    }
}

About

Simple pool of workers

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages