From f966695ccea356e4e4e8cc0328276e2d00c9fc1e Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Fri, 3 Jan 2025 11:47:39 -0800 Subject: context: use "canceled" in docs to refer to timed-out contexts In documentation, we've usually but not always referred to a context with a closed Done channel as "done" rather than "canceled", to avoid ambiguity between a context canceled by calling a CancelFunc and one past its deadline. This actually adds ambiguity, however, since it's common to see references to a "canceled context" that are intended to cover contexts past their deadline. If you see "function F returns if its context is canceled", you can reasonably assume that F will return if its context passes its deadline, unless something says otherwise. Update the context package docs to explicitly state that a context is canceled when its deadline passes. Drop references to contexts becoming "done" and just use "canceled" throughout. Fixes #70945 Change-Id: I99fbd800c6049deaa37015a304f7f9d9a84100e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/640095 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Damien Neil --- src/context/example_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/context/example_test.go') diff --git a/src/context/example_test.go b/src/context/example_test.go index b597b09f16..be8cd8376e 100644 --- a/src/context/example_test.go +++ b/src/context/example_test.go @@ -146,8 +146,8 @@ func ExampleAfterFunc_cond() { defer stopf() // Since the wakeups are using Broadcast instead of Signal, this call to - // Wait may unblock due to some other goroutine's context becoming done, - // so to be sure that ctx is actually done we need to check it in a loop. + // Wait may unblock due to some other goroutine's context being canceled, + // so to be sure that ctx is actually canceled we need to check it in a loop. for !conditionMet() { cond.Wait() if ctx.Err() != nil { -- cgit v1.3