aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/lockable.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/typeparam/lockable.go')
-rw-r--r--test/typeparam/lockable.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/typeparam/lockable.go b/test/typeparam/lockable.go
index d53817521f..9b20d87bb7 100644
--- a/test/typeparam/lockable.go
+++ b/test/typeparam/lockable.go
@@ -8,29 +8,29 @@ package main
import "sync"
-// A _Lockable is a value that may be safely simultaneously accessed
+// A Lockable is a value that may be safely simultaneously accessed
// from multiple goroutines via the Get and Set methods.
-type _Lockable[T any] struct {
- T
+type Lockable[T any] struct {
+ x T
mu sync.Mutex
}
-// Get returns the value stored in a _Lockable.
-func (l *_Lockable[T]) get() T {
+// Get returns the value stored in a Lockable.
+func (l *Lockable[T]) get() T {
l.mu.Lock()
defer l.mu.Unlock()
- return l.T
+ return l.x
}
-// set sets the value in a _Lockable.
-func (l *_Lockable[T]) set(v T) {
+// set sets the value in a Lockable.
+func (l *Lockable[T]) set(v T) {
l.mu.Lock()
defer l.mu.Unlock()
- l.T = v
+ l.x = v
}
func main() {
- sl := _Lockable[string]{T: "a"}
+ sl := Lockable[string]{x: "a"}
if got := sl.get(); got != "a" {
panic(got)
}
@@ -39,7 +39,7 @@ func main() {
panic(got)
}
- il := _Lockable[int]{T: 1}
+ il := Lockable[int]{x: 1}
if got := il.get(); got != 1 {
panic(got)
}