1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:14:41 -07:00

unique: clarify concurrent use of Make and Handle.Value

Fixes #69637.

Change-Id: Ie612b4df50f42f2786b22fb7a756949530f9178e
Reviewed-on: https://go-review.googlesource.com/c/go/+/616235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Michael Anthony Knyszek 2024-09-26 19:44:00 +00:00 committed by Gopher Robot
parent 1596a6c8ec
commit b7e4d2067c

View File

@ -25,12 +25,14 @@ type Handle[T comparable] struct {
}
// Value returns a shallow copy of the T value that produced the Handle.
// Value is safe for concurrent use by multiple goroutines.
func (h Handle[T]) Value() T {
return *h.value
}
// Make returns a globally unique handle for a value of type T. Handles
// are equal if and only if the values used to produce them are equal.
// Make is safe for concurrent use by multiple goroutines.
func Make[T comparable](value T) Handle[T] {
// Find the map for type T.
typ := abi.TypeFor[T]()