Atlas › Test

TestGoroMultiCancel

Exact test identity: go.temporal.io/server/common/goro/TestGoroMultiCancel

Package
go.temporal.io/server/common/goro
Suite / test hierarchy
TestGoroMultiCancel
Test
TestGoroMultiCancel
Introduced at
TestGoroMultiCancel Frontier kind: Test frontier
Covered ranges
7
Covered lines
30
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/goro/goro.go 23 covered LOC · 6 ranges

Open complete file

22 // the goroutine starts, which makes it possible for the goroutine to call
23 // Done() on itself (maybe indirectly) without a race condition.
24 > func NewHandle(ctx context.Context) *Handle { goro.go
25 > ctx, cancel := context.WithCancel(ctx)
26 > return &Handle{
27 > context: ctx,
28 > cancel: cancel,
29 > done: make(chan struct{}),
30 > }
31 > }
32
33 // Go launches the supplied function in its own goroutine. Go should be called
34 // exactly once on each *Handle.
35 > func (h *Handle) Go(f func(context.Context) error) *Handle { goro.go
36 > go func() {
37 > // use defer here so that the channel is closed even if the func calls
38 > // runtime.Goexit()
39 > defer close(h.done)
40 > if err := f(h.context); err != nil {
41 > h.err.Store(err) goro.go
42 > }
43 }()
44 > return h goro.go
45 }
46
49 // the Done() channel closing is the time taken by the goroutine to shut itself
50 // down.
51 > func (h *Handle) Done() <-chan struct{} { goro.go
52 > return h.done
53 > }
54
55 // Cancel requests that this goroutine stop by cancelling the associated context
56 // object. This function is threadsafe and idempotent. Note that this function
57 // _requests_ termination, it does not forcefully kill the goroutine.
58 > func (h *Handle) Cancel() { goro.go
59 > h.cancel()
60 > }
61
62 // Error observes the error returned by the func passed to Go (if any). There is
go.temporal.io/server/common/testing/parallelsuite/suite.go 7 covered LOC · 1 range

Open complete file

228 var inheritedMethods map[string]bool
229
230 > func init() { suite.go
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