12345678910111213141516171819202122232425 |
- 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() {}
|