-
Notifications
You must be signed in to change notification settings - Fork 23
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
Major refactor and cleanup #14
Conversation
wasm-bindgen no longer autostarts main on worker threads: rustwasm/wasm-bindgen#3236
@@ -13,19 +13,34 @@ categories = ["concurrency", "wasm"] | |||
readme = "README.md" | |||
|
|||
[features] | |||
default = ["es_modules"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only problem I had with the PR, I needed to update { default-features = false }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought module support is now common enough to be default. I will bump the version of course.
|
Using
Works, so 1097fe7 introduces some issues Edit: added my setup https://github.com/erwanvivien/gifski/tree/wasm_thread |
Is it crashing or just hanging? In later case, could it be that you are using |
It's neither crashing nor hanging, I will heck this tomorrow at work. But I think you're right, I'm not awaiting scoped threads |
I've been trying to check why we don't have anything running when using this branch, but I counldn't find it? Do you think this test should fail? #[wasm_bindgen_test]
async fn thread_messaging() {
use std::{
sync::mpsc::{channel, Receiver},
thread as std_thread,
};
let (tx, rx) = channel();
static ATOMIC_COUNT: AtomicUsize = AtomicUsize::new(0);
fn reader_callback(rx: Receiver<String>) {
while let Ok(_) = rx.recv() {
ATOMIC_COUNT.fetch_add(1, Ordering::Relaxed);
std_thread::sleep(Duration::from_millis(200));
}
}
let reader_thread = thread::Builder::new()
.name(String::from("reader"))
.spawn(|| reader_callback(rx))
.unwrap();
for i in 0..100 {
tx.send(format!("message {}", i)).unwrap();
}
let _ = thread::spawn(move || {
std_thread::sleep(Duration::from_millis(1100));
std::assert_eq!(ATOMIC_COUNT.load(Ordering::Relaxed), 6);
})
.join_async()
.await
.unwrap();
reader_thread.join_async().await.unwrap();
} I get this following stack trace:
I'm running the tests with this command: RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' \
wasm-pack test --headless --firefox --chrome --chromedriver /Users/erwanvivien/Downloads/chromedriver_mac64/chromedriver -- -Z build-std=panic_abort,std PS: Sorry for the long delay, we had to try integrate it fully to see if it worked |
Ok, I was a bit dumb: this is normal as it wait for the thread at the end for 200ms * 100 => which is exactly the test timeout |
This has been stuck for a while now and the only issue is the different worker despawn behavior, which can be worked around in user code. I will merge it and release bumping the minor version so it doesn't break anything. |
This is a large overhaul of the library as it has accumutaled a lot of code smell over time.
Major changes:
async-channel
dependency and implemented proper result exchange viaPacket
like in std lib. This should now allow async joins in the main thread where previously they would panic.available_parallelism()
andis_web_worker_thread()
.