From 1421b982dca738daf47fe11aec9b56050798d739 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Wed, 19 Feb 2025 17:28:45 +0000 Subject: [PATCH] runtime: document that cleanups can run concurrently with each other Fixes #71825. Change-Id: I25af19eb72d75f13cf661fc47ee5717782785326 Reviewed-on: https://go-review.googlesource.com/c/go/+/650696 Reviewed-by: Carlos Amedee LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt --- src/runtime/mcleanup.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/runtime/mcleanup.go b/src/runtime/mcleanup.go index 972532d475..d41a4971b5 100644 --- a/src/runtime/mcleanup.go +++ b/src/runtime/mcleanup.go @@ -30,8 +30,10 @@ import ( // unreachable at the same time, their cleanups all become eligible to run // and can run in any order. This is true even if the objects form a cycle. // -// A single goroutine runs all cleanup calls for a program, sequentially. If a -// cleanup function must run for a long time, it should create a new goroutine. +// Cleanups run concurrently with any user-created goroutines. +// Cleanups may also run concurrently with one another (unlike finalizers). +// If a cleanup function must run for a long time, it should create a new goroutine +// to avoid blocking the execution of other cleanups. // // If ptr has both a cleanup and a finalizer, the cleanup will only run once // it has been finalized and becomes unreachable without an associated finalizer. -- 2.51.0