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:
committed by
Andrey Nering
parent
f0cd7d27fb
commit
c6ecf70377
25
concurrency.go
Normal file
25
concurrency.go
Normal 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() {}
|
Reference in New Issue
Block a user