Skip to content

Commit fd6164c

Browse files
committed
clean up changes for lint
1 parent 5f8bd1b commit fd6164c

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

utils/mutex.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type atomicWatch[T any] struct {
4949
}
5050

5151
type AtomicSend[T any] struct {
52-
*atomicWatch[T]
52+
atomicWatch[T]
5353
}
5454

5555
// Store updates the value of the atomic watch.
@@ -67,22 +67,21 @@ func (w *AtomicSend[T]) Update(f func(T) (T, bool)) {
6767
}
6868

6969
func NewAtomicSend[T any](value T) (w AtomicSend[T]) {
70-
w.atomicWatch = &atomicWatch[T]{}
7170
w.ptr.Store(newVersion(value))
7271
// nolint:nakedret
7372
return
7473
}
7574

7675
func (w *AtomicSend[T]) Subscribe() AtomicRecv[T] {
77-
return AtomicRecv[T]{w.atomicWatch}
76+
return AtomicRecv[T]{&w.atomicWatch}
7877
}
7978

8079
// AtomicWatch stores a pointer to an IMMUTABLE value.
8180
// Loading and waiting for updates do NOT require locking.
8281
// TODO(gprusak): remove mutex and rename to AtomicSend,
8382
// this will allow for sharing a mutex across multiple AtomicSenders.
8483
type AtomicWatch[T any] struct {
85-
*atomicWatch[T]
84+
atomicWatch[T]
8685
mu sync.Mutex
8786
}
8887

@@ -98,7 +97,7 @@ func NewAtomicWatch[T any](value T) (w AtomicWatch[T]) {
9897

9998
// Subscribe returns a view-only API of the atomic watch.
10099
func (w *AtomicWatch[T]) Subscribe() AtomicRecv[T] {
101-
return AtomicRecv[T]{w.atomicWatch}
100+
return AtomicRecv[T]{&w.atomicWatch}
102101
}
103102

104103
// Load returns the current value of the atomic watch.
@@ -233,11 +232,3 @@ func (w *Watch[T]) Lock() iter.Seq2[T, *WatchCtrl] {
233232
_ = yield(w.val, &w.ctrl)
234233
}
235234
}
236-
237-
// Set updates the value and notifies all watchers
238-
func (w *Mutex[T]) Set(value T) {
239-
newVersion := newVersion(value)
240-
w.mu.Lock()
241-
defer w.mu.Unlock()
242-
w.value = newVersion.value
243-
}

0 commit comments

Comments
 (0)