fn/ContextGuard: clear store of cancel funcs

If ContextGuard lives for some time after Quit method is called, the map won't
be collected by GC. Optimization.
This commit is contained in:
Boris Nagaev
2024-12-14 15:15:40 -03:00
parent 1750aec13d
commit e9ab603735

View File

@@ -51,6 +51,10 @@ func (g *ContextGuard) Quit() {
cancel()
}
// Clear cancelFns. It is safe to use nil, because no write
// operations to it can happen after g.quit is closed.
g.cancelFns = nil
close(g.quit)
})
}