aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime2.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2025-05-20 15:56:43 -0700
committerGopher Robot <gobot@golang.org>2025-05-29 10:26:00 -0700
commitb170c7e94c478e616d194af95caa7747d9fa4725 (patch)
treeb77064b4707cc99d60d3727ba62a8fbc1a16ee25 /src/runtime/runtime2.go
parent3b77085b40bf0d53528d6852d07c00c81021c855 (diff)
downloadgo-b170c7e94c478e616d194af95caa7747d9fa4725.tar.xz
runtime, internal/synctest, sync: associate WaitGroups with bubbles
Add support to internal/synctest for managing associations between arbitrary pointers and synctest bubbles. (Implemented internally to the runtime package by attaching a special to the pointer.) Associate WaitGroups with bubbles. Since WaitGroups don't have a constructor, perform the association when Add is called. All Add calls must be made from within the same bubble, or outside any bubble. When a bubbled goroutine calls WaitGroup.Wait, the wait is durably blocking iff the WaitGroup is associated with the current bubble. Change-Id: I77e2701e734ac2fa2b32b28d5b0c853b7b2825c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/676656 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
-rw-r--r--src/runtime/runtime2.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go
index 94ab87f6db..cd40586bc2 100644
--- a/src/runtime/runtime2.go
+++ b/src/runtime/runtime2.go
@@ -1096,6 +1096,7 @@ const (
waitReasonSynctestChanReceive // "chan receive (synctest)"
waitReasonSynctestChanSend // "chan send (synctest)"
waitReasonSynctestSelect // "select (synctest)"
+ waitReasonSynctestWaitGroupWait // "sync.WaitGroup.Wait (synctest)"
waitReasonCleanupWait // "cleanup wait"
)
@@ -1145,6 +1146,7 @@ var waitReasonStrings = [...]string{
waitReasonSynctestChanReceive: "chan receive (synctest)",
waitReasonSynctestChanSend: "chan send (synctest)",
waitReasonSynctestSelect: "select (synctest)",
+ waitReasonSynctestWaitGroupWait: "sync.WaitGroup.Wait (synctest)",
waitReasonCleanupWait: "cleanup wait",
}
@@ -1190,18 +1192,18 @@ func (w waitReason) isIdleInSynctest() bool {
// isIdleInSynctest indicates that a goroutine is considered idle by synctest.Wait.
var isIdleInSynctest = [len(waitReasonStrings)]bool{
- waitReasonChanReceiveNilChan: true,
- waitReasonChanSendNilChan: true,
- waitReasonSelectNoCases: true,
- waitReasonSleep: true,
- waitReasonSyncCondWait: true,
- waitReasonSyncWaitGroupWait: true,
- waitReasonCoroutine: true,
- waitReasonSynctestRun: true,
- waitReasonSynctestWait: true,
- waitReasonSynctestChanReceive: true,
- waitReasonSynctestChanSend: true,
- waitReasonSynctestSelect: true,
+ waitReasonChanReceiveNilChan: true,
+ waitReasonChanSendNilChan: true,
+ waitReasonSelectNoCases: true,
+ waitReasonSleep: true,
+ waitReasonSyncCondWait: true,
+ waitReasonSynctestWaitGroupWait: true,
+ waitReasonCoroutine: true,
+ waitReasonSynctestRun: true,
+ waitReasonSynctestWait: true,
+ waitReasonSynctestChanReceive: true,
+ waitReasonSynctestChanSend: true,
+ waitReasonSynctestSelect: true,
}
var (