chemicstry / wasm_thread

A rust `std::thread` replacement for wasm32 target
Apache License 2.0
123 stars 16 forks source link

Feature flag to keep thread alive #21

Open vizigr0u opened 4 months ago

vizigr0u commented 4 months ago

While #18 is being discussed, this PR addresses one point which is only about closing the worker after the wasm entry point call.

This allows calling methods such as request_animation_frame, set_interval etc.

The responsibility to close the worker is passed to the user, with the helper function close_current_web_worker

chemicstry commented 4 months ago

Thanks for the PR!

However, since this is a temporary workaround until proper async entry point is implemented, I'm not very keen on merging it. But lets keep it open so people have something to patch in the meantime.

Tip for anyone wanting to use this (add to Cargo.toml):

[patch.crates-io]
wasm_thread = { git = "https://github.com/vizigr0u/wasm_thread", rev = "90c7f2b", features = ["keep_worker_alive"] }
vizigr0u commented 4 months ago

Tip for anyone wanting to use this (add to Cargo.toml):

[patch.crates-io]
wasm_thread = { git = "https://github.com/vizigr0u/wasm_thread", rev = "90c7f2b", features = ["keep_worker_alive"] }

Thank you, this is very useful