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:
1 file changed
+4
@@ -51,6 +51,10 @@ func (g *ContextGuard) Quit() {
|
|||||||
cancel()
|
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)
|
close(g.quit)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user