Skip to content

Commit

Permalink
taskgroup: clean up doc comments and add links
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Nov 6, 2024
1 parent 6cba8ab commit 0fbd363
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions taskgroup.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package taskgroup manages collections of cooperating goroutines.
// It defines a Group that handles waiting for goroutine termination and the
// propagation of error values. The caller may provide a callback to filter
// and respond to task errors.
// It defines a [Group] that handles waiting for goroutine termination and the
// propagation of error values. The caller may provide a callback to filter and
// respond to task errors.
package taskgroup

import (
Expand All @@ -11,14 +11,14 @@ import (
"sync/atomic"
)

// A Task function is the basic unit of work in a Group. Errors reported by
// A Task function is the basic unit of work in a [Group]. Errors reported by
// tasks are collected and reported by the group.
type Task func() error

// A Group manages a collection of cooperating goroutines. Add new tasks to
// the group with the Go method. Call the Wait method to wait for the tasks to
// complete. A zero value is ready for use, but must not be copied after its
// first use.
// the group with [Group.Go] and [Group.Run]. Call [Group.Wait] to wait for
// the tasks to complete. A zero value is ready for use, but must not be copied
// after its first use.
//
// The group collects any errors returned by the tasks in the group. The first
// non-nil error reported by any task (and not otherwise filtered) is returned
Expand Down Expand Up @@ -124,7 +124,7 @@ func (g *Group) handleError(err error) {
// returns the first non-nil error reported by any of the goroutines in the
// group and not filtered by an OnError callback.
//
// As with sync.WaitGroup, new tasks can be added to g during a call to Wait
// As with [sync.WaitGroup], new tasks can be added to g during a call to Wait
// only if the group contains at least one active task when Wait is called and
// continuously thereafter until the last concurrent call to g.Go returns.
//
Expand Down
6 changes: 3 additions & 3 deletions throttle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "sync/atomic"

// A Throttle rate-limits the number of concurrent goroutines that can execute
// in parallel to some fixed number. A zero Throttle is ready for use, but
// imposes no limit on parallel execution. See [Throttle.Enter] for use.
// imposes no limit on parallel execution.
type Throttle struct {
adm chan struct{}
}
Expand All @@ -18,8 +18,8 @@ func NewThrottle(n int) Throttle {
return Throttle{adm: make(chan struct{}, n)}
}

// enter blocks until a slot is available in t, then returns a [Leaver] that
// the caller must execute to return the slot when it is no longer in use.
// enter blocks until a slot is available in t, then returns a leaver that the
// caller must execute to return the slot when it is no longer in use.
func (t Throttle) enter() leaver {
if t.adm == nil {
return func() {}
Expand Down

0 comments on commit 0fbd363

Please sign in to comment.