Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syscall/js: document more clearly how early js.Func can be released #38152

Closed
dmitshur opened this issue Mar 29, 2020 · 1 comment
Closed

syscall/js: document more clearly how early js.Func can be released #38152

dmitshur opened this issue Mar 29, 2020 · 1 comment
Labels
arch-wasm WebAssembly issues Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Mar 29, 2020

The documentation for js.Func currently says:

Func.Release must be called to free up resources when the function will not be used any more.

Release frees up resources allocated for the function. The function must not be invoked after calling Release.

Based on a comment from @neelance and my understanding of the code, it seems the intention is for it to be safe to release a js.Func at a time when no future invocations of the js.Func will be made. An invocation here means the time the execution begins. So, if a js.Func will only be invoked once, it is safe to release a js.Func right away in the Go function that will be executing:

var f js.Func
f = js.FuncOf(func(this js.Value, args []js.Value) interface{} {
    f.Release() // okay, even though this Go function is still in the middle of executing
    ...

I believe the documentation needs to make this more clear, so that users can rely on this behavior.

/cc @neelance @hajimehoshi @johanbrandhorst

@dmitshur dmitshur added Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues OS-JS labels Mar 29, 2020
@dmitshur dmitshur added this to the Backlog milestone Mar 29, 2020
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/235138 mentions this issue: syscall/js: improve documentation of Func.Release

@dmitshur dmitshur modified the milestones: Backlog, Go1.15 May 24, 2020
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 24, 2020
@golang golang locked and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-JS
Projects
None yet
Development

No branches or pull requests

2 participants