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

refactor: webWorker is optionally passed on last argument #1032

Merged
merged 30 commits into from
Jan 10, 2024

Conversation

thewtex
Copy link
Member

@thewtex thewtex commented Dec 22, 2023

Re #1018

@thewtex thewtex force-pushed the web-worker-option branch 3 times, most recently from b1e90c8 to 5ea2242 Compare January 5, 2024 04:19
@thewtex thewtex requested a review from PaulHax January 5, 2024 04:19
Copy link
Collaborator

@PaulHax PaulHax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API change makes sense to me. In the future, are you thinking of automaticly terminating the worker in runPipeline if no worker option is passed?

In runPipeline and bindgen browser typescript functions, the webWorker
is no longer the first argument but passed on the last options argument.

BREAKING_CHANGE: webWorker is optionally passed on last argument
A way to identify that a worker has been terminated.
This prevents the need to call .terminate() on the work to avoid
resource leaks. .terminate() can still be called, but the worker is
re-used by default for performance.
@thewtex
Copy link
Member Author

thewtex commented Jan 6, 2024

I added a commit so that calling .terminate() is not necessary to avoid resource leaks by default. While .terminate() still can optionally be called to release memory, the default behavior is to re-use the worker, which is a better performance / memory usage tradeoff in most use cases. Creating the worker is not that expensive, but instantiating the wasm module and allocating the memory it uses is expensive.

…efault

To avoid detached buffers, copy ArrayBuffer's for inputs by default.
This is not necessary for outputs, where ownership is transferred to the
caller. For cases where the inputs are not needed further, a `noCopy`
option can be explicitly passed.
And add API description in README's.
webWorker is moved from the first argument to a property on the last
`options` argument. See also commit 1268a9a
@thewtex thewtex changed the title WIP: refactor: webWorker is optionally passed on last argument refactor: webWorker is optionally passed on last argument Jan 9, 2024
@thewtex thewtex marked this pull request as ready for review January 9, 2024 04:24
@thewtex thewtex merged commit e2d6a5a into InsightSoftwareConsortium:main Jan 10, 2024
105 of 111 checks passed
@thewtex thewtex deleted the web-worker-option branch January 10, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants