You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Releasing thread and URL reference when the workerized function is not needed #49
Great library, very useful stuff and absolutely love the size. :)
I've only recently started learning about Web Workers and took a look at the source code. So apologies in advance if I am wrong ;). 2 things caught my eyes:
constworkerURL=URL.createObjectURL(newBlob([script]));// Create an "inline" worker (1:1 at definition time)constworker=newWorker(workerURL);
So if we do something like the following snippet (taken from the README), it seems that each new function instantiated via greenlet(...) will reserve a new thread and a new URL reference.
So, if there is a case wherein I don't need to use getName after a certain point in my code, those resources are still trapped. They may be very less in size to be of a practical concern, but I am not sure about it and would love if anyone can comment on that.
However, if the output function getName comes with a dispose method which releases those references, it could be useful. WDYT? Something like:
Post dispose, getName can itself become undefined so it's not callable. Or can throw a more informative error: The function is disposed/discarded due to .dispose() call..
Is there a downside to this approach if the contributors already considered any similar approach?
Activity
ljluestc commentedon Nov 23, 2023