Skip to content

Commit fe3591b

Browse files
berbreikgopherbot
authored andcommitted
sync/errgroup: improve documentation for semaphore limit behavior
Updated the documentation for `SetLimit` and `Go` functions in the `errgroup` package. the note clarifies the behavior when the semaphore limit is set to zero, which could lead to a deadlock if not handled properly. the updated documentation warns users to set a positive semaphore limit to avoid blocking goroutines and potential deadlock this change improves the clarity of API and helps users understand how to properly use the semaphore limit to prevent issues in concurrent execution Change-Id: Ie62acc38ef804b3590c04bddba00a3cce21e8cef Reviewed-on: https://go-review.googlesource.com/c/sync/+/642215 Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 913fb63 commit fe3591b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

errgroup/errgroup.go

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func (g *Group) TryGo(f func() error) bool {
118118

119119
// SetLimit limits the number of active goroutines in this group to at most n.
120120
// A negative value indicates no limit.
121+
// A limit of zero will prevent any new goroutines from being added.
121122
//
122123
// Any subsequent call to the Go method will block until it can add an active
123124
// goroutine without exceeding the configured limit.

0 commit comments

Comments
 (0)