Atlas › Test
TestKeyedSet_ConcurrentSync
Exact test identity: go.temporal.io/server/common/goro/TestKeyedSet_ConcurrentSync
- Package
go.temporal.io/server/common/goro
- Suite / test hierarchy
TestKeyedSet_ConcurrentSync
- Test
TestKeyedSet_ConcurrentSync
- Introduced at
- keyed_set.go ×2 Frontier kind: Joint frontier
- Covered ranges
- 8
- Covered lines
- 28
- Covered files
- 2
Co-introduced tests
2 other tests enter at the same concept.
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/goro/keyed_set.go 21 covered LOC · 7 ranges
Open complete file
15
16
// NewKeyedSet returns a new KeyedSet where all goroutines inherit a context from baseCtx.
17
>
func NewKeyedSet[K comparable](baseCtx context.Context) *KeyedSet[K] {
keyed_set.go
18
>
return &KeyedSet[K]{
19
>
baseCtx: baseCtx,
20
>
cancels: make(map[K]context.CancelFunc),
21
>
}
22
>
}
23
24
// Sync cancels/starts goroutines as necessary so that the running set matches the set of keys
32
// returns and is removed, but the caller of f thinks it's now active. In other words, there
33
// should be one source of truth for what should be running.
34
>
func (s *KeyedSet[K]) Sync(target map[K]struct{}, f func(context.Context, K)) {
keyed_set.go
35
>
s.lock.Lock()
36
>
defer s.lock.Unlock()
37
>
38
>
for key, cancel := range s.cancels {
40
>
cancel()
41
>
delete(s.cancels, key)
42
>
}
43
}
44
48
}
49
>
ctx, cancel := context.WithCancel(s.baseCtx)
keyed_set.go
50
>
s.cancels[key] = cancel
51
>
go f(ctx, key)
52
}
53
}
go.temporal.io/server/common/testing/parallelsuite/suite.go 7 covered LOC · 1 range
Open complete file
228
var inheritedMethods map[string]bool
229
231
>
type ds struct{ Suite[*ds] }
232
>
ptrType := reflect.TypeFor[*ds]()
233
>
inheritedMethods = make(map[string]bool, ptrType.NumMethod())
234
>
for method := range ptrType.Methods() {
235
>
inheritedMethods[method.Name] = true
236
>
}
237
}
238