Stream: rust-toolchain

Topic: Semantics of `wit_bindgen::spawn`


view this post on Zulip Lann Martin (Oct 13 2025 at 13:40):

https://docs.rs/wit-bindgen/0.46.0/wit_bindgen/fn.spawn.html

Defer the specified future to be run after the current async-lifted export task has returned a value.

IIUC this means that the spawning task will deadlock if it waits on something that the spawned task will do, right? That makes sense to me but I wonder if we should name this something other than spawn since you can't use it for things that you would naturally use thread or tokio spawn for. How about defer?

view this post on Zulip Lann Martin (Oct 13 2025 at 13:44):

Relatedly, would it make sense to include a basic wit_bindgen::join(fut_a, fut_b)? You can always pull in e.g. futures-lite but this seems fundamental enough that it might be worth including anyway.

view this post on Zulip Alex Crichton (Oct 13 2025 at 14:23):

The wording here isn't quite right, your situation wouldn't deadlock because it actually progresses both tasks concurrently - needs a doc update

view this post on Zulip Alex Crichton (Oct 13 2025 at 14:23):

And yeah having some simple future combinators seems reasonable to me

view this post on Zulip Lann Martin (Oct 13 2025 at 14:25):

Did this change since 0.46?

view this post on Zulip Lann Martin (Oct 13 2025 at 14:26):

I blamed a deadlock on this, just curious if I was mistaken.

view this post on Zulip Alex Crichton (Oct 13 2025 at 14:37):

nah it's always been the case that spawned tasks progress in parallel with the main task

view this post on Zulip Pat Hickey (Oct 13 2025 at 16:30):

fun fact: futures-lite doesnt even include join :(

view this post on Zulip Lann Martin (Oct 13 2025 at 16:30):

It calls it zip :shrug:

view this post on Zulip Pat Hickey (Oct 13 2025 at 16:31):

whaaaaaaa

view this post on Zulip Pat Hickey (Oct 13 2025 at 16:31):

god dammit why did they do that


Last updated: Dec 06 2025 at 05:03 UTC