mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-23 13:59:02 +00:00
runtime: implement dummy AddCleanup
This commit is contained in:
committed by
Ron Evans
parent
d6343d9d5c
commit
5c46efb4d1
@@ -106,6 +106,25 @@ func UnlockOSThread() {
|
|||||||
// point of the call.
|
// point of the call.
|
||||||
func KeepAlive(x interface{})
|
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)
|
var godebugUpdate func(string, string)
|
||||||
|
|
||||||
//go:linkname godebug_setUpdate internal/godebug.setUpdate
|
//go:linkname godebug_setUpdate internal/godebug.setUpdate
|
||||||
|
|||||||
Reference in New Issue
Block a user