mirror of
https://github.com/go-task/task.git
synced 2024-12-12 10:45:49 +02:00
26 lines
436 B
Go
26 lines
436 B
Go
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() {}
|