Skip to content

Commit 066eac1

Browse files
committed
use satisfied to make them bools
Signed-off-by: Scott Nichols <[email protected]>
1 parent 68a06ac commit 066eac1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/gate/gate.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424

2525
// Gate implements a gated function callback registration with comparable conditions.
2626
type Gate[T comparable] struct {
27-
mux sync.RWMutex
28-
conditions map[T]bool
29-
fns []gated[T]
27+
mux sync.RWMutex
28+
satisfied map[T]bool
29+
fns []gated[T]
3030
}
3131

3232
// gated is an internal tracking resource.
@@ -55,16 +55,16 @@ func (g *Gate[T]) Register(fn func(), depends ...T) {
5555
func (g *Gate[T]) Set(condition T, value bool) bool {
5656
g.mux.Lock()
5757

58-
if g.conditions == nil {
59-
g.conditions = make(map[T]bool)
58+
if g.satisfied == nil {
59+
g.satisfied = make(map[T]bool)
6060
}
6161

62-
old, found := g.conditions[condition]
62+
old, found := g.satisfied[condition]
6363

6464
updated := false
6565
if !found || old != value {
6666
updated = true
67-
g.conditions[condition] = value
67+
g.satisfied[condition] = value
6868
}
6969
// process() would also like to lock the mux, so we must unlock here directly and not use defer.
7070
g.mux.Unlock()
@@ -85,7 +85,7 @@ func (g *Gate[T]) process() {
8585
release := true
8686

8787
for _, dep := range g.fns[i].depends {
88-
if !g.conditions[dep] {
88+
if !g.satisfied[dep] {
8989
release = false
9090
}
9191
}

0 commit comments

Comments
 (0)