package pool import "sync" // Pool - type Pool struct { queue chan bool wg *sync.WaitGroup } // NewPool - func NewPool(size int) *Pool { if size < 1 { size = 1 } p := &Pool{ queue: make(chan bool, size), wg: &sync.WaitGroup{}, } return p } // Add - func (p *Pool) Add() { p.queue <- true p.wg.Add(1) } // Done - func (p *Pool) Done() { <-p.queue p.wg.Done() } // Wait - func (p *Pool) Wait() { p.wg.Wait() }