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

js: Properly manage workers when useWorkers is called twice #626

Merged
merged 1 commit into from
Oct 31, 2023
Merged

Commits on Oct 29, 2023

  1. js: Properly manage workers when useWorkers is called twice

    Before this change, calling useWorkers twice would allocate new workers
    but keep old workers around; this resulted in old workers leaking when
    the new count was larger; when the new count was smaller, we would still
    maintain the worker count but recreate some workers and leak older ones.
    
    Instead we now only create more workers if more workers are requested,
    and if the requested count is smaller than current worker count, we ask
    some existing workers (nicely) to close by sending a dummy message.
    
    Because messages are processed in order, and processing the worker
    response does not access global workers[], it should be safe to call
    useWorkers(0) at any point without disrupting already dispatched
    requests. This also provides a clean way to reclaim all resources used
    by the workers, including WebAssembly memory.
    zeux committed Oct 29, 2023
    Configuration menu
    Copy the full SHA
    8a2fc4d View commit details
    Browse the repository at this point in the history