diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-24 21:24:17 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-24 21:24:17 +0200 |
| commit | e7972d4a84ed33dc48ced73b15e567ea2f6bb033 (patch) | |
| tree | b131487a2ac4162b427dc5fb612ca344550a585a /internal/flamegraph/worker.go | |
| parent | 03ee58c0e018a9493f50ac1cb45bf40899935cf9 (diff) | |
flamegraph: replace worker busy-wait with blocking select
Diffstat (limited to 'internal/flamegraph/worker.go')
| -rw-r--r-- | internal/flamegraph/worker.go | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/internal/flamegraph/worker.go b/internal/flamegraph/worker.go index 534bfc3..0f49568 100644 --- a/internal/flamegraph/worker.go +++ b/internal/flamegraph/worker.go @@ -4,7 +4,6 @@ import ( "context" "ior/internal/event" "sync" - "time" ) type worker struct { @@ -21,17 +20,14 @@ func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pa for { select { - case ev := <-ch: - w.iod.addEventPair(ev) - ev.Recycle() - - default: - select { - case <-ctx.Done(): + case ev, ok := <-ch: + if !ok { return - default: - time.Sleep(time.Millisecond * 10) } + w.iod.addEventPair(ev) + ev.Recycle() + case <-ctx.Done(): + return } } } |
