5 ms·
The article doesn’t actually explain how they work… How does the indirect pointer get set to nil? Does it use runtime.SetFinalizer?
by njtransit 2y ago
The article doesn’t actually explain how they work… How does the indirect pointer get set to nil? Does it use runtime.SetFinalizer?
- usrnm 2y agohttps://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/internal/weak/pointer.go;l=62 https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/... https://cs.opensource.google/go/go/+/master:src/runtime/mheap.go;l=2068 https://cs.opensource.google/go/go/+/master:src/runtime/mhea... Looks like most of it is implemented directly in the runtime.