From 0bfde51e0d98097fed74e7a3e86e96da259325e1 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Wed, 19 Feb 2025 17:28:45 +0000 Subject: [PATCH] [release-branch.go1.24] runtime: document that cleanups can run concurrently with each other For #71825. Fixes #71955. Change-Id: I25af19eb72d75f13cf661fc47ee5717782785326 Reviewed-on: https://go-review.googlesource.com/c/go/+/652637 Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Knyszek Reviewed-by: Keith Randall --- 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.48.1