Skip to content

Commit e9ab603

Browse files
committed
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.
1 parent 1750aec commit e9ab603

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fn/context_guard.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func (g *ContextGuard) Quit() {
5151
cancel()
5252
}
5353

54+
// Clear cancelFns. It is safe to use nil, because no write
55+
// operations to it can happen after g.quit is closed.
56+
g.cancelFns = nil
57+
5458
close(g.quit)
5559
})
5660
}

0 commit comments

Comments
 (0)