Skip to content

Commit

Permalink
sync/errgroup: improve documentation for semaphore limit behavior
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
berbreik authored and gopherbot committed Jan 17, 2025
1 parent 913fb63 commit fe3591b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions errgroup/errgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (g *Group) TryGo(f func() error) bool {

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

0 comments on commit fe3591b

Please sign in to comment.