diff --git a/limited_runner.go b/limited_runner.go index 75e4630..c571649 100644 --- a/limited_runner.go +++ b/limited_runner.go @@ -22,7 +22,7 @@ func NewLimitedRunner(routineLimit int) *LimitedRunner { func (r *LimitedRunner) Run(f func()) { r.limiter <- struct{}{} go func() { + defer func() { <-r.limiter }() f() - <-r.limiter }() }