1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Adding a --concurrency (-C) flag

This commit is contained in:
Ross Hammermeister
2020-06-12 12:09:53 -06:00
committed by Andrey Nering
parent f0cd7d27fb
commit c6ecf70377
6 changed files with 119 additions and 22 deletions

25
concurrency.go Normal file
View File

@@ -0,0 +1,25 @@
package task
func (e *Executor) acquireConcurrencyLimit() func() {
if e.concurrencySemaphore == nil {
return emptyFunc
}
e.concurrencySemaphore <- struct{}{}
return func() {
<-e.concurrencySemaphore
}
}
func (e *Executor) releaseConcurrencyLimit() func() {
if e.concurrencySemaphore == nil {
return emptyFunc
}
<-e.concurrencySemaphore
return func() {
e.concurrencySemaphore <- struct{}{}
}
}
func emptyFunc() {}