joker8023 / go-coroutines-pool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-coroutines-pool

pool for go coroutines

Table of Contents

Requirements

requires the following to run:

  • go ^1.12.6

Usage

package main

import (
	"log"
	"time"

	pool "github.com/joker8023/go-coroutines-pool"
)

func main() {
	pool := pool.New(3)
	for i := 0; i < 10; i++ {
		pool.Add(1)
		go func(num int) {
			time.Sleep(time.Second)
			log.Printf("num:%d", num)
			pool.Done()
		}(i)
	}
	pool.Wait()
}


Build


   go build

About

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%