Skip to content

Commit d805c22

Browse files
committed
cue: explicitly document values are not safe for concurrent use
Users are regularly confused by data races or other panics caused by the concurrent use of the API in this package, particularly when making concurrent use of values. Even though Go APIs are generally not safe for concurrent use unless documented otherwise, per https://go.dev/issue/30632, it can be easy to forget that since concurrency is so common in Go. Add an explicit reminder about it, following our reasoning from the last time we discussed the current state of concurrency in the API. While here, make a few godoc link tweaks. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I8a7d3a5855e41781fb188adf79fd0bb4171d01e9 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1172256 Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 8f88dcb commit d805c22

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cue/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (r *hiddenRuntime) Build(p *build.Instance) (*Instance, error) {
117117
return r.complete(p, v)
118118
}
119119

120-
// Deprecated: [Context.BuildInstances]. The use of [Instance] is being phased out.
120+
// Deprecated: use [Context.BuildInstances]. The use of [Instance] is being phased out.
121121
func Build(instances []*build.Instance) []*Instance {
122122
if len(instances) == 0 {
123123
panic("cue: list of instances must not be empty")

cue/cue.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
// Package cue is the main API for CUE evaluation.
1616
//
17-
// Value is the main type that represents CUE evaluations. Values are created
18-
// with a cue.Context. Only values created from the same Context can be
19-
// involved in the same operation.
17+
// [Value] is the main type that represents CUE evaluations.
18+
// Values are created with a [cuecontext.Context].
19+
// Only values created from the same Context can be involved in the same operation.
20+
// Values created from the same Context are not safe for concurrent use,
21+
// which we intend to change in the future.
2022
//
2123
// A Context defines the set of active packages, the translations of field
2224
// names to unique codes, as well as the set of builtins. Use
@@ -30,10 +32,10 @@
3032
// Note that the following types are DEPRECATED and their usage should be
3133
// avoided if possible:
3234
//
33-
// FieldInfo
34-
// Instance
35-
// Runtime
36-
// Struct
35+
// [FieldInfo]
36+
// [Instance]
37+
// [Runtime]
38+
// [Struct]
3739
//
3840
// Many types also have deprecated methods. Code that already uses deprecated
3941
// methods can keep using them for at least some time. We aim to provide a

0 commit comments

Comments
 (0)