diff options
Diffstat (limited to 'test/typeparam/lockable.go')
| -rw-r--r-- | test/typeparam/lockable.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/typeparam/lockable.go b/test/typeparam/lockable.go index d53817521f..3a03652cd8 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 { +type Lockable[T any] struct { 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 } -// 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 } func main() { - sl := _Lockable[string]{T: "a"} + sl := Lockable[string]{T: "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]{T: 1} if got := il.get(); got != 1 { panic(got) } |
