From 0fbd363be68f39b1754c6263023a4ad1adc47b89 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Wed, 6 Nov 2024 08:40:44 -0800 Subject: [PATCH] taskgroup: clean up doc comments and add links --- taskgroup.go | 16 ++++++++-------- throttle.go | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/taskgroup.go b/taskgroup.go index 6727c17..a1179e3 100644 --- a/taskgroup.go +++ b/taskgroup.go @@ -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 ( @@ -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 @@ -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. // diff --git a/throttle.go b/throttle.go index 8b8059d..12abe27 100644 --- a/throttle.go +++ b/throttle.go @@ -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{} } @@ -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() {}