runtime: implement dummy AddCleanup

This commit is contained in:
Ayke van Laethem
2025-07-31 13:51:17 +02:00
committed by Ron Evans
parent d6343d9d5c
commit 5c46efb4d1
+19
View File
@@ -106,6 +106,25 @@ func UnlockOSThread() {
// point of the call.
func KeepAlive(x interface{})
// AddCleanup is a dummy cleanup implementation. It doesn't do any cleaning up.
//
// We base this on the following loophole in the official runtime.AddCleanup
// documentation:
//
// > The cleanup(arg) call is not always guaranteed to run; in particular it is
// > not guaranteed to run before program exit.
//
// So it's technically correct (the best kind of correct) to not run any
// cleanups. But of course, this can lead to resource leaks so cleanups may need
// to be implemented eventually.
func AddCleanup[T, S any](ptr *T, cleanup func(S), arg S) Cleanup {
return Cleanup{}
}
type Cleanup struct{}
func (c Cleanup) Stop() {}
var godebugUpdate func(string, string)
//go:linkname godebug_setUpdate internal/godebug.setUpdate