func (p *Manager) release() {
	p.wg.Done()
	<-p.semaphore
}
release releases the acquired semaphore to signal that a task is finished.
package parallel
import (
	"runtime"
	"sync"
)
const (
	minNumWorkers = 2
)
type Task func() error
type Manager struct {
	wg        *sync.WaitGroup
	semaphore chan bool
}
func New(workercount int) *Manager {
	if workercount < 0 {
		workercount = runtime.NumCPU() * -workercount
	}
	if workercount < minNumWorkers {
		workercount = minNumWorkers
	}
	return &Manager{
		wg:        &sync.WaitGroup{},
		semaphore: make(chan bool, workercount),
	}
}
func (p *Manager) acquire() {
	p.semaphore <- true
	p.wg.Add(1)
}