Go calls the given function in a new goroutine. It blocks until the new goroutine can be added without the number of active goroutines in the group exceeding the configured limit.
(f func() error)
| 53 | // It blocks until the new goroutine can be added without the number of |
| 54 | // active goroutines in the group exceeding the configured limit. |
| 55 | func (g *ErrWaitGroup) Go(f func() error) { |
| 56 | if g.sem != nil { |
| 57 | g.sem <- token{} |
| 58 | } |
| 59 | |
| 60 | g.wg.Add(1) |
| 61 | go func() { |
| 62 | defer g.done() |
| 63 | |
| 64 | if err := f(); err != nil { |
| 65 | g.mu.Lock() |
| 66 | g.err = Join(g.err, err) |
| 67 | g.mu.Unlock() |
| 68 | } |
| 69 | }() |
| 70 | } |
| 71 | |
| 72 | // TryGo calls the given function in a new goroutine only if the number of |
| 73 | // active goroutines in the group is currently below the configured limit. |
no test coverage detected