runtime: put a bool in front of initialization-done channel
Calls to Go functions from threads not started by Go have to wait
for Go initialization to be complete. Before this CL they did this
by receiving from a channel that is closed when initialization is done.
That works well but introduces a channel operation into cgo calls.
This is particularly frustrating because the channel is approximately
always closed.
This CL adds an atomic bool before the channel, so that in the normal
case we are just adding a single locked memory load. We still use
the channel as a fallback.
For #77522
Change-Id: I8f609bf349bb0f836cefa5f6ad6d0c3c7bbfe5e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/743940 Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>